0001-mbedtls-check-version-for-cipher-id.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 0c4b4c1e93c8e869af230090f32346fdfd548f21 Mon Sep 17 00:00:00 2001
  2. From: Stefan Eissing <stefan@eissing.org>
  3. Date: Wed, 22 May 2024 14:44:56 +0200
  4. Subject: [PATCH] mbedtls: check version for cipher id
  5. mbedtls_ssl_get_ciphersuite_id_from_ssl() seems to have been added in
  6. mbedtls 3.2.0. Check for that version.
  7. Closes #13749
  8. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  9. Upstream: https://github.com/curl/curl/commit/0c4b4c1e93c8e869af230090f32346fdfd548f21
  10. ---
  11. lib/vtls/mbedtls.c | 19 ++++++++++++-------
  12. 1 file changed, 12 insertions(+), 7 deletions(-)
  13. diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
  14. index ec0b10dd9a9f..98a4ea01b183 100644
  15. --- a/lib/vtls/mbedtls.c
  16. +++ b/lib/vtls/mbedtls.c
  17. @@ -902,8 +902,6 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data)
  18. (struct mbed_ssl_backend_data *)connssl->backend;
  19. struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf);
  20. const mbedtls_x509_crt *peercert;
  21. - char cipher_str[64];
  22. - uint16_t cipher_id;
  23. #ifndef CURL_DISABLE_PROXY
  24. const char * const pinnedpubkey = Curl_ssl_cf_is_proxy(cf)?
  25. data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY]:
  26. @@ -932,11 +930,18 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data)
  27. return CURLE_SSL_CONNECT_ERROR;
  28. }
  29. - cipher_id = (uint16_t)
  30. - mbedtls_ssl_get_ciphersuite_id_from_ssl(&backend->ssl);
  31. - mbed_cipher_suite_get_str(cipher_id, cipher_str, sizeof(cipher_str), true);
  32. - infof(data, "mbedTLS: Handshake complete, cipher is %s", cipher_str);
  33. -
  34. +#if MBEDTLS_VERSION_NUMBER >= 0x03020000
  35. + {
  36. + char cipher_str[64];
  37. + uint16_t cipher_id;
  38. + cipher_id = (uint16_t)
  39. + mbedtls_ssl_get_ciphersuite_id_from_ssl(&backend->ssl);
  40. + mbed_cipher_suite_get_str(cipher_id, cipher_str, sizeof(cipher_str), true);
  41. + infof(data, "mbedTLS: Handshake complete, cipher is %s", cipher_str);
  42. + }
  43. +#else
  44. + infof(data, "mbedTLS: Handshake complete");
  45. +#endif
  46. ret = mbedtls_ssl_get_verify_result(&backend->ssl);
  47. if(!conn_config->verifyhost)
  48. --
  49. 2.43.0