From e79fe4b8f0d2f9acd3a6b664328d0852af46173b Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Tue, 2 Oct 2018 17:53:35 +0300 Subject: [PATCH] Update mbedTLS to 2.13.1 CL: Update mbedTLS to 2.13.1 PUBLISHED_FROM=bd1216f727605a901f062a044c0c0ca762f4a6d1 --- mongoose.c | 12 +++++------- src/mg_ssl_if_mbedtls.c | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/mongoose.c b/mongoose.c index ed2db8d6..1949e628 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5192,9 +5192,9 @@ static void mg_ssl_if_mbed_free_certs_and_keys(struct mg_ssl_if_ctx *ctx) { if (ctx->ca_cert != NULL) { mbedtls_ssl_conf_ca_chain(ctx->conf, NULL, NULL); #ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK - if (ctx->ca_cert->ca_chain_file != NULL) { - MG_FREE((void *) ctx->ca_cert->ca_chain_file); - ctx->ca_cert->ca_chain_file = NULL; + if (ctx->conf->ca_chain_file != NULL) { + MG_FREE((void *) ctx->conf->ca_chain_file); + ctx->conf->ca_chain_file = NULL; } #endif mbedtls_x509_crt_free(ctx->ca_cert); @@ -5301,15 +5301,13 @@ static enum mg_ssl_if_result mg_use_ca_cert(struct mg_ssl_if_ctx *ctx, mbedtls_x509_crt_init(ctx->ca_cert); #ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK ca_cert = strdup(ca_cert); - if (mbedtls_x509_crt_set_ca_chain_file(ctx->ca_cert, ca_cert) != 0) { - return MG_SSL_ERROR; - } + mbedtls_ssl_conf_ca_chain_file(ctx->conf, ca_cert, NULL); #else if (mbedtls_x509_crt_parse_file(ctx->ca_cert, ca_cert) != 0) { return MG_SSL_ERROR; } -#endif mbedtls_ssl_conf_ca_chain(ctx->conf, ctx->ca_cert, NULL); +#endif mbedtls_ssl_conf_authmode(ctx->conf, MBEDTLS_SSL_VERIFY_REQUIRED); return MG_SSL_OK; } diff --git a/src/mg_ssl_if_mbedtls.c b/src/mg_ssl_if_mbedtls.c index 9656e557..7640778f 100644 --- a/src/mg_ssl_if_mbedtls.c +++ b/src/mg_ssl_if_mbedtls.c @@ -223,9 +223,9 @@ static void mg_ssl_if_mbed_free_certs_and_keys(struct mg_ssl_if_ctx *ctx) { if (ctx->ca_cert != NULL) { mbedtls_ssl_conf_ca_chain(ctx->conf, NULL, NULL); #ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK - if (ctx->ca_cert->ca_chain_file != NULL) { - MG_FREE((void *) ctx->ca_cert->ca_chain_file); - ctx->ca_cert->ca_chain_file = NULL; + if (ctx->conf->ca_chain_file != NULL) { + MG_FREE((void *) ctx->conf->ca_chain_file); + ctx->conf->ca_chain_file = NULL; } #endif mbedtls_x509_crt_free(ctx->ca_cert); @@ -332,15 +332,13 @@ static enum mg_ssl_if_result mg_use_ca_cert(struct mg_ssl_if_ctx *ctx, mbedtls_x509_crt_init(ctx->ca_cert); #ifdef MBEDTLS_X509_CA_CHAIN_ON_DISK ca_cert = strdup(ca_cert); - if (mbedtls_x509_crt_set_ca_chain_file(ctx->ca_cert, ca_cert) != 0) { - return MG_SSL_ERROR; - } + mbedtls_ssl_conf_ca_chain_file(ctx->conf, ca_cert, NULL); #else if (mbedtls_x509_crt_parse_file(ctx->ca_cert, ca_cert) != 0) { return MG_SSL_ERROR; } -#endif mbedtls_ssl_conf_ca_chain(ctx->conf, ctx->ca_cert, NULL); +#endif mbedtls_ssl_conf_authmode(ctx->conf, MBEDTLS_SSL_VERIFY_REQUIRED); return MG_SSL_OK; }