Skip to content

Commit 84faff4

Browse files
committed
WL#12755: Fix issue whith connections to openssl 1.0 servers when connector is built and used with openssl 1.1
If connector that supports TLSv1.3 was connecting to a server which supports up to TLSv1.2, connection failed if any ciphers were specified (and default TLS version list was used), but succeeded if no cipher specified or TLS version was explicitly set to TLSv1.2.
1 parent d270b92 commit 84faff4

File tree

2 files changed

+227
-233
lines changed

2 files changed

+227
-233
lines changed

cdk/foundation/connection_openssl.cc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,19 @@ void TLS_helper::setup(SSL_CTX *ctx)
362362
);
363363

364364
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
365+
366+
if (m_ver_min)
367+
{
365368
if (1 != SSL_CTX_set_min_proto_version(ctx, m_ver_min))
366369
throw_openssl_error();
370+
}
367371

372+
if (m_ver_max)
373+
{
368374
if (1 != SSL_CTX_set_max_proto_version(ctx, m_ver_max))
369375
throw_openssl_error();
376+
}
377+
370378
#endif
371379

372380
long result_mask = SSL_CTX_set_options(ctx, m_ver_mask);
@@ -392,7 +400,23 @@ void TLS_helper::setup(SSL_CTX *ctx)
392400
SSL_CTX_set_cipher_list(ctx, m_cipher_list.c_str());
393401

394402
#if OPENSSL_VERSION_NUMBER>=0x1010100fL
395-
SSL_CTX_set_ciphersuites(ctx, m_cipher_list_13.c_str());
403+
404+
/*
405+
Note: If TLSv1.3 is not enabled, there is no need to restrict
406+
1.3 ciphers as they won't be used anyway. Also, it turns out
407+
that setting any 1.3 ciphers while TLSv1.3 is not disabled breaks
408+
connections that otherwise could down-grade to TLSv1.2. As if
409+
calling SSL_CTX_set_ciphersuites() in this situation would set
410+
minimum TLS version to TLSv1.3.
411+
412+
Note: m_ver_max == 0 means that there is no limit.
413+
*/
414+
415+
if (!m_ver_max || m_ver_max > TLS1_2_VERSION)
416+
{
417+
SSL_CTX_set_ciphersuites(ctx, m_cipher_list_13.c_str());
418+
}
419+
396420
#endif
397421

398422
}

0 commit comments

Comments
 (0)