1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Secure Component */ 17 /** */ 18 /** Transport Layer Security (TLS) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define NX_SECURE_SOURCE_CODE 24 25 26 #include "nx_secure_tls.h" 27 28 /* Bring in externs for caller checking code. */ 29 30 NX_SECURE_CALLER_CHECKING_EXTERNS 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _nxe_secure_tls_session_certificate_callback_set PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Timothy Stapko, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function checks for errors when setting the TLS certificate */ 45 /* verification callback function. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* tls_session TLS control block */ 50 /* func_ptr Pointer to callback function */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* status Completion status */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _nx_secure_tls_session_certificate_callback_set */ 59 /* Actual callback function set */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* Application Code */ 64 /* */ 65 /* RELEASE HISTORY */ 66 /* */ 67 /* DATE NAME DESCRIPTION */ 68 /* */ 69 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 70 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 71 /* resulting in version 6.1 */ 72 /* */ 73 /**************************************************************************/ _nxe_secure_tls_session_certificate_callback_set(NX_SECURE_TLS_SESSION * tls_session,ULONG (* func_ptr)(NX_SECURE_TLS_SESSION * session,NX_SECURE_X509_CERT * certificate))74UINT _nxe_secure_tls_session_certificate_callback_set(NX_SECURE_TLS_SESSION *tls_session, 75 ULONG (*func_ptr)(NX_SECURE_TLS_SESSION *session, 76 NX_SECURE_X509_CERT *certificate)) 77 { 78 UINT status; 79 80 81 if (tls_session == NX_NULL || func_ptr == NX_NULL) 82 { 83 return(NX_PTR_ERROR); 84 } 85 86 /* Make sure the session is initialized. */ 87 if(tls_session -> nx_secure_tls_id != NX_SECURE_TLS_ID) 88 { 89 return(NX_SECURE_TLS_SESSION_UNINITIALIZED); 90 } 91 92 /* Check for appropriate caller. */ 93 NX_THREADS_ONLY_CALLER_CHECKING 94 95 /* Call the actual function. */ 96 status = _nx_secure_tls_session_certificate_callback_set(tls_session, func_ptr); 97 98 return(status); 99 } 100 101