From 28cc9b5d98179d161673d20e79333ae5a4864228 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sat, 4 May 2024 19:40:07 +0800 Subject: [PATCH] Add compatibility with Mbed TLS 3.0.0 Signed-off-by: Jianhui Zhao Upstream: https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228 [thomas: - Apply to submodule directory - Rename 'urandom' to '_urandom' - Adapt line numbers ] Signed-off-by: Thomas Perale --- src/ssl/mbedtls.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ssl/mbedtls.c b/src/ssl/mbedtls.c index 2e02e1c..cad7e00 100644 --- a/src/ssl/mbedtls.c +++ b/src/ssl/mbedtls.c @@ -49,7 +49,6 @@ #include "ssl.h" #include -#include #include #include #include @@ -136,9 +135,13 @@ static const int default_ciphersuites_client[] = AES_CBC_CIPHERS(ECDHE_ECDSA), AES_CBC_CIPHERS(ECDHE_RSA), AES_CBC_CIPHERS(DHE_RSA), +#ifdef MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, +#endif AES_CIPHERS(RSA), +#ifdef MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, +#endif 0 }; @@ -221,7 +224,7 @@ static void ssl_update_own_cert(struct ssl_context *ctx) if (!ctx->cert.version) return; - if (!ctx->key.pk_info) + if (mbedtls_pk_get_type(&ctx->key) == MBEDTLS_PK_NONE) return; mbedtls_ssl_conf_own_cert(&ctx->conf, &ctx->cert, &ctx->key); @@ -258,7 +261,11 @@ int ssl_load_key_file(struct ssl_context *ctx, const char *file) { int ret; +#if (MBEDTLS_VERSION_NUMBER >= 0x03000000) + ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL, _urandom, NULL); +#else ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL); +#endif if (ret) return -1;