Skip to content

Commit 7487ad1

Browse files
Use existing session context if new is actually NULL (#2946)
SSL_set_SSL_CTX() doesn't currently tolerate the ctx argument being NULL (it would just crash in some cases). I was pondering handling this by just explicitly error out if it was NULL. But I realised upstream OpenSSL has a different behaviour: falls back to existing session context from ssl. This is unnecessary complexity, but in the name of interoperability I did that instead of flipping to an error state.
1 parent cb37cb0 commit 7487ad1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ssl/ssl_lib.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2856,7 +2856,8 @@ SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx) {
28562856
if (!ssl->config) {
28572857
return NULL;
28582858
}
2859-
if (ssl->ctx.get() == ctx) {
2859+
2860+
if (!ctx || ssl->ctx.get() == ctx) {
28602861
return ssl->ctx.get();
28612862
}
28622863

0 commit comments

Comments
 (0)