1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** NetX Secure Component */
16 /** */
17 /** Transport Layer Security (TLS) */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SECURE_SOURCE_CODE
23
24 #include "nx_secure_tls.h"
25
26 /**************************************************************************/
27 /* */
28 /* FUNCTION RELEASE */
29 /* */
30 /* _nx_secure_tls_session_sni_extension_set PORTABLE C */
31 /* 6.2.0 */
32 /* AUTHOR */
33 /* */
34 /* Timothy Stapko, Microsoft Corporation */
35 /* */
36 /* DESCRIPTION */
37 /* */
38 /* This function checks sets the DNS Name in a TLS client for the */
39 /* Server Name Indication (SNI) extension (RFC 6066). The current RFC */
40 /* specifies that only a single DNS Name entry is allowed in the SNI */
41 /* extension data. If other name types are added in the future, new */
42 /* API will be added. */
43 /* */
44 /* INPUT */
45 /* */
46 /* tls_session TLS control block */
47 /* dns_name Pointer to the server name */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* status Completion status */
52 /* */
53 /* CALLS */
54 /* */
55 /* None */
56 /* */
57 /* CALLED BY */
58 /* */
59 /* Application Code */
60 /* */
61 /* RELEASE HISTORY */
62 /* */
63 /* DATE NAME DESCRIPTION */
64 /* */
65 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
66 /* 09-30-2020 Timothy Stapko Modified comment(s), */
67 /* resulting in version 6.1 */
68 /* 10-31-2022 Yanwu Cai Modified comment(s), */
69 /* fix compile error, */
70 /* resulting in version 6.2.0 */
71 /* */
72 /**************************************************************************/
_nx_secure_tls_session_sni_extension_set(NX_SECURE_TLS_SESSION * tls_session,NX_SECURE_X509_DNS_NAME * dns_name)73 UINT _nx_secure_tls_session_sni_extension_set(NX_SECURE_TLS_SESSION *tls_session,
74 NX_SECURE_X509_DNS_NAME *dns_name)
75 {
76 #ifndef NX_SECURE_TLS_SNI_EXTENSION_DISABLED
77
78 /* Set the pointer to the SNI DNS name so it can be sent in the ClientHello. */
79 tls_session -> nx_secure_tls_sni_extension_server_name = dns_name;
80
81 return(NX_SUCCESS);
82 #else
83 NX_PARAMETER_NOT_USED(tls_session);
84 NX_PARAMETER_NOT_USED(dns_name);
85
86 return(NX_NOT_ENABLED);
87 #endif
88 }
89
90