Skip to content

Commit

Permalink
mbedtls: Fix ssl_init error with mbedTLS 3.1.0+
Browse files Browse the repository at this point in the history
Since mbedTLS 3.1.0, mbedtls_ssl_setup() fails if the provided
config struct is not valid.

mbedtls_ssl_config_defaults() needs to be called before the config
struct is passed to mbedtls_ssl_setup().

Closes #8238
  • Loading branch information
Koromix authored and bagder committed Jan 9, 2022
1 parent d148312 commit 919baa5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/vtls/mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,6 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn,
infof(data, "mbedTLS: Connecting to %s:%ld", hostname, port);

mbedtls_ssl_config_init(&backend->config);

mbedtls_ssl_init(&backend->ssl);
if(mbedtls_ssl_setup(&backend->ssl, &backend->config)) {
failf(data, "mbedTLS: ssl_init failed");
return CURLE_SSL_CONNECT_ERROR;
}
ret = mbedtls_ssl_config_defaults(&backend->config,
MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
Expand All @@ -484,6 +478,12 @@ mbed_connect_step1(struct Curl_easy *data, struct connectdata *conn,
return CURLE_SSL_CONNECT_ERROR;
}

mbedtls_ssl_init(&backend->ssl);
if(mbedtls_ssl_setup(&backend->ssl, &backend->config)) {
failf(data, "mbedTLS: ssl_init failed");
return CURLE_SSL_CONNECT_ERROR;
}

/* new profile with RSA min key len = 1024 ... */
mbedtls_ssl_conf_cert_profile(&backend->config,
&mbedtls_x509_crt_profile_fr);
Expand Down

0 comments on commit 919baa5

Please sign in to comment.