From 3e3c270f76d3c6bc97f4bb484e61d8c8c8eeacac Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 27 Feb 2018 08:26:01 +0800 Subject: [PATCH] LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT: fixes after tls refactor https://github.com/warmcat/libwebsockets/issues/1191 --- lib/http2/ssl-http2.c | 3 +++ lib/server/ssl-server.c | 2 +- lib/ssl.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/http2/ssl-http2.c b/lib/http2/ssl-http2.c index 592a73dd9..894fa71ba 100644 --- a/lib/http2/ssl-http2.c +++ b/lib/http2/ssl-http2.c @@ -103,6 +103,9 @@ int lws_h2_configure_if_upgraded(struct lws *wsi) char cstr[10]; unsigned len; + if (!wsi->ssl) + return 0; + SSL_get0_alpn_selected(wsi->ssl, &name, &len); if (!len) { lwsl_info("no ALPN upgrade\n"); diff --git a/lib/server/ssl-server.c b/lib/server/ssl-server.c index a9516f223..c4362824b 100644 --- a/lib/server/ssl-server.c +++ b/lib/server/ssl-server.c @@ -155,7 +155,7 @@ lws_ssl_server_name_cb(SSL *ssl, int *ad, void *arg) */ vh = context->vhost_list; while (vh) { - if (!vh->being_destroyed && vh->ssl_ctx == SSL_get_SSL_CTX(ssl)) + if (!vh->being_destroyed && ssl && vh->ssl_ctx == SSL_get_SSL_CTX(ssl)) break; vh = vh->vhost_next; } diff --git a/lib/ssl.c b/lib/ssl.c index 007dd3ef5..755d06db4 100644 --- a/lib/ssl.c +++ b/lib/ssl.c @@ -904,7 +904,7 @@ accepted: /* adapt our vhost to match the SNI SSL_CTX that was chosen */ vh = context->vhost_list; while (vh) { - if (!vh->being_destroyed && + if (!vh->being_destroyed && wsi->ssl && vh->ssl_ctx == SSL_get_SSL_CTX(wsi->ssl)) { lwsl_info("setting wsi to vh %s\n", vh->name); wsi->vhost = vh;