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 /**************************************************************************/
29 /* */
30 /* FUNCTION RELEASE */
31 /* */
32 /* _nx_secure_tls_session_certificate_callback_set PORTABLE C */
33 /* 6.1 */
34 /* AUTHOR */
35 /* */
36 /* Timothy Stapko, Microsoft Corporation */
37 /* */
38 /* DESCRIPTION */
39 /* */
40 /* This function sets up a function pointer that TLS will invoke when */
41 /* a certificate is received from a remote host, allowing the */
42 /* application to perform validation checks such as DNS validation, */
43 /* certificate revocation, and certificate policy enforcement. */
44 /* */
45 /* NetX Secure TLS will perform basic validation on the certificate */
46 /* before invoking the callback to assure that the certificate can be */
47 /* traced to a certificate in the TLS trusted certificate store, but */
48 /* all other validation will be handled by this callback. */
49 /* */
50 /* The callback provides the TLS session pointer and a pointer to the */
51 /* remote host identity certificate (the leaf in the certificate */
52 /* chain). The callback should return NX_SUCCESS if all validation is */
53 /* successful, otherwise it should return an error code indicating the */
54 /* validation failure. Any value other than NX_SUCCESS will cause the */
55 /* TLS handshake to immediately abort. */
56 /* */
57 /* INPUT */
58 /* */
59 /* tls_session TLS control block */
60 /* func_ptr Pointer to callback function */
61 /* */
62 /* OUTPUT */
63 /* */
64 /* status Completion status */
65 /* */
66 /* CALLS */
67 /* */
68 /* None */
69 /* */
70 /* CALLED BY */
71 /* */
72 /* Application Code */
73 /* */
74 /* RELEASE HISTORY */
75 /* */
76 /* DATE NAME DESCRIPTION */
77 /* */
78 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
79 /* 09-30-2020 Timothy Stapko Modified comment(s), */
80 /* resulting in version 6.1 */
81 /* */
82 /**************************************************************************/
_nx_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))83 UINT _nx_secure_tls_session_certificate_callback_set(NX_SECURE_TLS_SESSION *tls_session,
84 ULONG (*func_ptr)(NX_SECURE_TLS_SESSION *session,
85 NX_SECURE_X509_CERT *certificate))
86 {
87 /* Set the function pointer in the TLS session. */
88 tls_session -> nx_secure_tls_session_certificate_callback = func_ptr;
89
90 return(NX_SUCCESS);
91 }
92
93