diff --git a/lib/context.c b/lib/context.c index 447c96c5..635bb137 100644 --- a/lib/context.c +++ b/lib/context.c @@ -214,24 +214,15 @@ libwebsocket_create_context(struct lws_context_creation_info *info) sizeof(struct libwebsocket), sizeof(struct allocated_headers)); - -#ifdef LWS_OPENSSL_SUPPORT - if (info->provided_client_ssl_ctx){ - //use the provided OpenSSL context if given one - context->ssl_client_ctx = info->provided_client_ssl_ctx; - context->user_supplied_ssl_ctx = 1; //mark to not delet the context on cleanup - } -#endif - if (lws_context_init_server_ssl(info, context)) + if (lws_context_init_server_ssl(info, context)) goto bail; - if (!context->ssl_client_ctx && lws_context_init_client_ssl(info, context)) + + if (lws_context_init_client_ssl(info, context)) goto bail; if (lws_context_init_server(info, context)) goto bail; - lwsl_debug(" client SSL ctx %p\n", context->ssl_client_ctx); - lwsl_debug(" server SSL ctx %p\n", context->ssl_ctx); /* * drop any root privs for this process * to listen on port < 1023 we would have needed root, but now we are diff --git a/lib/ssl-http2.c b/lib/ssl-http2.c index 237f43cd..673bf672 100644 --- a/lib/ssl-http2.c +++ b/lib/ssl-http2.c @@ -50,6 +50,7 @@ #include "private-libwebsockets.h" #ifndef LWS_NO_SERVER +#ifdef LWS_OPENSSL_SUPPORT #if OPENSSL_VERSION_NUMBER >= 0x10002000L static int alpn_select_proto_cb(SSL* ssl, @@ -75,4 +76,5 @@ lws_context_init_http2_ssl(struct libwebsocket_context *context) #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L } +#endif #endif \ No newline at end of file diff --git a/lib/ssl.c b/lib/ssl.c index cc86b805..ab632393 100644 --- a/lib/ssl.c +++ b/lib/ssl.c @@ -238,6 +238,14 @@ int lws_context_init_client_ssl(struct lws_context_creation_info *info, int n; SSL_METHOD *method; + if (info->provided_client_ssl_ctx) { + /* use the provided OpenSSL context if given one */ + context->ssl_client_ctx = info->provided_client_ssl_ctx; + /* nothing for lib to delete */ + context->user_supplied_ssl_ctx = 1; + return 0; + } + if (info->port != CONTEXT_PORT_NO_LISTEN) return 0;