Need to protect members with MBEDTLS_PK_C and X509_CRT_PARSE flags.

This is dependency to X509_CRT_PARSE but just to make sure
that also the 'mbedtls_pk_context' structure is not used if that
flag is not enabled.
pull/8659/head
Seppo Takalo 2018-11-14 16:13:36 +02:00
parent 46c46019bc
commit 2229a2f2f5
2 changed files with 7 additions and 4 deletions

View File

@ -48,7 +48,9 @@ TLSSocketWrapper::TLSSocketWrapper(Socket *transport, const char *hostname, cont
mbedtls_entropy_init(&_entropy);
mbedtls_ctr_drbg_init(&_ctr_drbg);
mbedtls_ssl_init(&_ssl);
#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_pk_init(&_pkctx);
#endif
if (hostname) {
set_hostname(hostname);
@ -63,9 +65,8 @@ TLSSocketWrapper::~TLSSocketWrapper()
mbedtls_entropy_free(&_entropy);
mbedtls_ctr_drbg_free(&_ctr_drbg);
mbedtls_ssl_free(&_ssl);
#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_pk_free(&_pkctx);
#ifdef MBEDTLS_X509_CRT_PARSE_C
set_own_cert(NULL);
set_ca_chain(NULL);
#endif
@ -119,7 +120,7 @@ nsapi_error_t TLSSocketWrapper::set_client_cert_key(const char *client_cert_pem,
nsapi_error_t TLSSocketWrapper::set_client_cert_key(const void *client_cert, size_t client_cert_len,
const void *client_private_key_pem, size_t client_private_key_len)
{
#if !defined(MBEDTLS_X509_CRT_PARSE_C)
#if !defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_PK_C)
return NSAPI_ERROR_UNSUPPORTED;
#else
@ -483,7 +484,7 @@ int TLSSocketWrapper::ssl_send(void *ctx, const unsigned char *buf, size_t len)
return size;
}
#ifdef MBEDTLS_X509_CRT_PARSE_C
#if defined(MBEDTLS_X509_CRT_PARSE_C)
mbedtls_x509_crt *TLSSocketWrapper::get_own_cert()
{

View File

@ -232,7 +232,9 @@ private:
static int ssl_send(void *ctx, const unsigned char *buf, size_t len);
mbedtls_ssl_context _ssl;
#ifdef MBEDTLS_X509_CRT_PARSE_C
mbedtls_pk_context _pkctx;
#endif
mbedtls_ctr_drbg_context _ctr_drbg;
mbedtls_entropy_context _entropy;