/*************************************************************************** * Copyright (c) 2024 Microsoft Corporation * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Secure Component */ /** */ /** Transport Layer Security (TLS) */ /** */ /**************************************************************************/ /**************************************************************************/ #define NX_SECURE_SOURCE_CODE /* Include necessary system files. */ #include "nx_secure_tls.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _nx_secure_tls_server_certificate_add PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function adds a local certificate specifically for a TLS */ /* server with a unique integer identifier for use in TLS extensions */ /* that support multiple certificates. */ /* */ /* INPUT */ /* */ /* tls_session Pointer to TLS Session */ /* certificate Pointer to certificate */ /* cert_id Unique ID for certificate */ /* */ /* OUTPUT */ /* */ /* status Completion status */ /* */ /* CALLS */ /* */ /* _nx_secure_tls_local_certificate_add Add local certificate to */ /* TLS session */ /* */ /* CALLED BY */ /* */ /* Application Code */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ /* */ /**************************************************************************/ UINT _nx_secure_tls_server_certificate_add(NX_SECURE_TLS_SESSION *tls_session, NX_SECURE_X509_CERT *certificate, UINT cert_id) { UINT status; /* A cert_id of 0 is reserved for certificates that are keyed by distinguished name. */ if (cert_id == 0) { return(NX_SECURE_TLS_CERT_ID_INVALID); } /* Set the ID for this certificate. */ certificate -> nx_secure_x509_cert_identifier = cert_id; /* Add the certificate. */ status = _nx_secure_tls_local_certificate_add(tls_session, certificate); /* Return completion status. */ return(status); }