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
25 /* Include necessary system files. */
26
27 #include "nx_secure_tls.h"
28
29 /**************************************************************************/
30 /* */
31 /* FUNCTION RELEASE */
32 /* */
33 /* _nx_secure_tls_server_certificate_remove PORTABLE C */
34 /* 6.2.1 */
35 /* AUTHOR */
36 /* */
37 /* Timothy Stapko, Microsoft Corporation */
38 /* */
39 /* DESCRIPTION */
40 /* */
41 /* This function removes a server certificate from a TLS session X.509 */
42 /* certificate store based on the unique ID assigned when the */
43 /* certificate was added to the store with */
44 /* nx_secure_tls_server_certificate_add. */
45 /* */
46 /* INPUT */
47 /* */
48 /* tls_session Pointer to TLS Session */
49 /* cert_id Certificate identifier */
50 /* */
51 /* OUTPUT */
52 /* */
53 /* status Completion status */
54 /* */
55 /* CALLS */
56 /* */
57 /* _nx_secure_x509_store_certificate_remove */
58 /* Remove server certificate */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application Code */
63 /* */
64 /* RELEASE HISTORY */
65 /* */
66 /* DATE NAME DESCRIPTION */
67 /* */
68 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */
69 /* 09-30-2020 Timothy Stapko Modified comment(s), */
70 /* resulting in version 6.1 */
71 /* 04-02-2021 Timothy Stapko Modified comment(s), */
72 /* updated X.509 return value, */
73 /* resulting in version 6.1.6 */
74 /* 03-08-2023 Yanwu Cai Modified comment(s), */
75 /* fixed compiler errors when */
76 /* x509 is disabled, */
77 /* resulting in version 6.2.1 */
78 /* */
79 /**************************************************************************/
_nx_secure_tls_server_certificate_remove(NX_SECURE_TLS_SESSION * tls_session,UINT cert_id)80 UINT _nx_secure_tls_server_certificate_remove(NX_SECURE_TLS_SESSION *tls_session, UINT cert_id)
81 {
82 #ifndef NX_SECURE_DISABLE_X509
83 UINT status;
84
85 /* Remove the certificate from the local store. */
86 status = _nx_secure_x509_store_certificate_remove(&tls_session -> nx_secure_tls_credentials.nx_secure_tls_certificate_store,
87 NX_NULL, NX_SECURE_X509_CERT_LOCATION_LOCAL, cert_id);
88
89 /* Translate some X.509 return values into TLS return values. */
90 if (status == NX_SECURE_X509_CERTIFICATE_NOT_FOUND)
91 {
92 return(NX_SECURE_TLS_CERTIFICATE_NOT_FOUND);
93 }
94
95 /* Return completion status. */
96 return(status);
97 #else
98 NX_PARAMETER_NOT_USED(tls_session);
99 NX_PARAMETER_NOT_USED(cert_id);
100
101 return(NX_NOT_SUPPORTED);
102 #endif
103 }
104
105