Skip to content

Commit 2ae8f21

Browse files
committed
ssl: call SSL_CTX_set_ecdh_auto() on OpenSSL 1.0.2 only
SSL_CTX_set_ecdh_auto() exists in OpenSSL 1.1.0 and LibreSSL 2.6.1, but it is made no-op and the automatic curve selection cannot be disabled. Wrap it with ifdef to make it clear that it is safe to remove it completely when we drop support for OpenSSL 1.0.2.
1 parent c055938 commit 2ae8f21

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ ossl_sslctx_s_alloc(VALUE klass)
9393
RTYPEDDATA_DATA(obj) = ctx;
9494
SSL_CTX_set_ex_data(ctx, ossl_sslctx_ex_ptr_idx, (void *)obj);
9595

96-
#if !defined(OPENSSL_NO_EC)
96+
#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER < 0x10100000 && \
97+
!defined(LIBRESSL_VERSION_NUMBER)
9798
/* We use SSL_CTX_set1_curves_list() to specify the curve used in ECDH. It
9899
* allows to specify multiple curve names and OpenSSL will select
99100
* automatically from them. In OpenSSL 1.0.2, the automatic selection has to
100-
* be enabled explicitly. But OpenSSL 1.1.0 removed the knob and it is
101-
* always enabled. To uniform the behavior, we enable the automatic
102-
* selection also in 1.0.2. Users can still disable ECDH by removing ECDH
103-
* cipher suites by SSLContext#ciphers=. */
101+
* be enabled explicitly. OpenSSL 1.1.0 and LibreSSL 2.6.1 removed the knob
102+
* and it is always enabled. To uniform the behavior, we enable the
103+
* automatic selection also in 1.0.2. Users can still disable ECDH by
104+
* removing ECDH cipher suites by SSLContext#ciphers=. */
104105
if (!SSL_CTX_set_ecdh_auto(ctx, 1))
105106
ossl_raise(eSSLError, "SSL_CTX_set_ecdh_auto");
106107
#endif

0 commit comments

Comments
 (0)