Skip to content

Commit

Permalink
SSL_CTX_new can fail
Browse files Browse the repository at this point in the history
SSLv23_ methods deprecated
  • Loading branch information
scaprile committed Jul 9, 2024
1 parent a9902b5 commit f60a92b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -12567,8 +12567,12 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
s_initialised++;
}
MG_DEBUG(("%lu Setting TLS", c->id));
tls->ctx = c->is_client ? SSL_CTX_new(SSLv23_client_method())
: SSL_CTX_new(SSLv23_server_method());
tls->ctx = c->is_client ? SSL_CTX_new(TLS_client_method())
: SSL_CTX_new(TLS_server_method());
if (tls->ctx == NULL) {
mg_error(c, "SSL_CTX_new");
goto fail;
}
#ifdef MG_TLS_SSLKEYLOGFILE
SSL_CTX_set_keylog_callback(tls->ctx, ssl_keylog_cb);
#endif
Expand Down
8 changes: 6 additions & 2 deletions src/tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
s_initialised++;
}
MG_DEBUG(("%lu Setting TLS", c->id));
tls->ctx = c->is_client ? SSL_CTX_new(SSLv23_client_method())
: SSL_CTX_new(SSLv23_server_method());
tls->ctx = c->is_client ? SSL_CTX_new(TLS_client_method())
: SSL_CTX_new(TLS_server_method());
if (tls->ctx == NULL) {
mg_error(c, "SSL_CTX_new");
goto fail;
}
#ifdef MG_TLS_SSLKEYLOGFILE
SSL_CTX_set_keylog_callback(tls->ctx, ssl_keylog_cb);
#endif
Expand Down

0 comments on commit f60a92b

Please sign in to comment.