From 455d1fed06769efe695a7bbb85e34d353142a656 Mon Sep 17 00:00:00 2001 From: Larry Hayes Date: Tue, 15 Jan 2013 01:03:58 +0800 Subject: [PATCH] ssl client certs fix crash I run a web socket server that requires clients to present a certificate. context_ssl_ = libwebsocket_create_context(wssPort_, wssIpAddr_.c_str(), protocols_ssl, libwebsocket_internal_extensions, cert_path.c_str(), key_path.c_str(), -1, -1, LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT); I am getting a crash in the OpenSSL_verify_callback(). The SSL_get_ex_data() call is returning NULL I could not find a call to SSL_set_ex_data() for server mode operation. Has anyone seen this crash in the newer versions? Signed-off-by: Larry Hayes --- lib/libwebsockets.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 242bc729..c084cfc5 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -1593,8 +1593,6 @@ libwebsocket_service_fd(struct libwebsocket_context *context, break; } - /* accepting connection to main listener */ - new_wsi = libwebsocket_create_new_server_wsi(context); if (new_wsi == NULL) { #ifdef WIN32 @@ -1628,6 +1626,9 @@ libwebsocket_service_fd(struct libwebsocket_context *context, break; } + SSL_set_ex_data(new_wsi->ssl, + openssl_websocket_private_data_index, context); + SSL_set_fd(new_wsi->ssl, accept_fd); n = SSL_accept(new_wsi->ssl);