Skip to content

Commit 003e145

Browse files
committed
Prefer SSL_CTX_set_options over SSL_CTX_ctrl
As indicated by SSL_CTRL_OPTIONS no longer being defined, we should avoid it as much as possible.
1 parent 4f9674e commit 003e145

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/generic/OpenSSLConnection.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ OpenSSLConnection::SSLFuncs::SSLFuncs()
4545

4646
valid = valid && LoadSymbol(CTX_new, sslhandle, "SSL_CTX_new");
4747
valid = valid && LoadSymbol(CTX_ctrl, sslhandle, "SSL_CTX_ctrl");
48+
if (valid)
49+
LoadSymbol(CTX_set_options, sslhandle, "SSL_CTX_set_options");
4850
valid = valid && LoadSymbol(CTX_set_verify, sslhandle, "SSL_CTX_set_verify");
4951
valid = valid && LoadSymbol(CTX_set_default_verify_paths, sslhandle, "SSL_CTX_set_default_verify_paths");
5052
valid = valid && LoadSymbol(CTX_free, sslhandle, "SSL_CTX_free");
@@ -87,7 +89,10 @@ OpenSSLConnection::OpenSSLConnection()
8789
if (!context)
8890
return;
8991

90-
ssl.CTX_ctrl(context, SSL_CTRL_OPTIONS, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3, nullptr);
92+
if (ssl.CTX_set_options)
93+
ssl.CTX_set_options(context, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
94+
else
95+
ssl.CTX_ctrl(context, SSL_CTRL_OPTIONS, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3, nullptr);
9196
ssl.CTX_set_verify(context, SSL_VERIFY_PEER, nullptr);
9297
ssl.CTX_set_default_verify_paths(context);
9398
}

src/generic/OpenSSLConnection.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class OpenSSLConnection : public Connection
3636

3737
SSL_CTX *(*CTX_new)(const SSL_METHOD *method);
3838
long (*CTX_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
39+
long (*CTX_set_options)(SSL_CTX *ctx, long options);
3940
void (*CTX_set_verify)(SSL_CTX *ctx, int mode, void *verify_callback);
4041
int (*CTX_set_default_verify_paths)(SSL_CTX *ctx);
4142
void (*CTX_free)(SSL_CTX *ctx);

0 commit comments

Comments
 (0)