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 necessary system files. */
27
28 #include "nx_secure_tls.h"
29
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* _nx_secure_tls_active_certificate_set PORTABLE C */
35 /* 6.2.1 */
36 /* AUTHOR */
37 /* */
38 /* Timothy Stapko, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function sets the active local certificate, overriding any */
43 /* previously added local certificates. Normally, a single certificate */
44 /* is used for a TLS instance, but in some cases the server or client */
45 /* may need to choose a specific certificate during the handshake. By */
46 /* calling this function in the TLS server or client callback, an */
47 /* application can choose the active local certificate at runtime */
48 /* after a ClientHello or ServerHello is received. */
49 /* */
50 /* NOTE: The certificate MUST be in the local store before calling */
51 /* this function (using nx_secure_tls_local_certificate_add) or the */
52 /* proper certificate chain may not be sent to the remote host! */
53 /* */
54 /* INPUT */
55 /* */
56 /* tls_session Pointer to TLS Session */
57 /* certificate Pointer to certificate */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* status Completion status */
62 /* */
63 /* CALLS */
64 /* */
65 /* None */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* Application Code */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
76 /* 09-30-2020 Timothy Stapko Modified comment(s), */
77 /* resulting in version 6.1 */
78 /* 03-08-2023 Yanwu Cai Modified comment(s), */
79 /* fixed compiler errors when */
80 /* x509 is disabled, */
81 /* resulting in version 6.2.1 */
82 /* */
83 /**************************************************************************/
_nx_secure_tls_active_certificate_set(NX_SECURE_TLS_SESSION * tls_session,NX_SECURE_X509_CERT * certificate)84 UINT _nx_secure_tls_active_certificate_set(NX_SECURE_TLS_SESSION *tls_session,
85 NX_SECURE_X509_CERT *certificate)
86 {
87 #ifdef NX_SECURE_DISABLE_X509
88 NX_PARAMETER_NOT_USED(tls_session);
89 NX_PARAMETER_NOT_USED(certificate);
90
91 return(NX_NOT_SUPPORTED);
92 #else
93 /* Set the active certificate (should be in the store). */
94 tls_session -> nx_secure_tls_credentials.nx_secure_tls_active_certificate = certificate;
95
96 /* Return completion status. */
97 return(NX_SUCCESS);
98 #endif
99 }
100
101