Skip to content

Commit ab2900e

Browse files
committed
Fix version bug with ecdh
1 parent 7e89983 commit ab2900e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/source/Crypto/Dtls_openssl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,16 @@ STATUS createSslCtx(PDtlsSessionCertificateInfo pCertificates, UINT32 certCount,
245245

246246
CHK(pSslCtx != NULL, STATUS_SSL_CTX_CREATION_FAILED);
247247

248-
// Version less than 1.1.0
249-
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
250-
SSL_CTX_set_ecdh_auto(pSslCtx, TRUE);
251-
252-
// Version less than 3.0.0 and greater than 1.1.0
253-
#elif (OPENSSL_VERSION_NUMBER < 0x30000000L)
248+
// https://www.openssl.org/docs/man1.0.2/man3/
249+
// https://www.openssl.org/docs/man1.1.1/man3/
250+
// Version < 3.0.0
251+
#if (OPENSSL_VERSION_NUMBER < 0x30000000L)
254252
CHK((ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1)) != NULL, STATUS_SSL_CTX_CREATION_FAILED);
255253
CHK(SSL_CTX_set_tmp_ecdh(pSslCtx, ecdh) == 1, STATUS_SSL_CTX_CREATION_FAILED);
256254
#else
257-
DLOGI("ECDH enabled by default in 3.0.0. Nothing to do");
255+
// https://www.openssl.org/docs/man3.0/man3/EC_KEY_new_by_curve_name.html -- indicates that EC_KEY_new_by_curve_name and SSL_CTX_set_tmp_ecdh are
256+
// deprecated https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_set1_groups.html
257+
CHK(SSL_CTX_set1_groups_list(pSslCtx, "prime256v1") == 1, STATUS_SSL_CTX_CREATION_FAILED);
258258
#endif
259259

260260
SSL_CTX_set_verify(pSslCtx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, dtlsCertificateVerifyCallback);

0 commit comments

Comments
 (0)