From 4076a2c8bc7f94dfa8c7b4251d9ea02ec9d2d74a Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 20 Nov 2014 12:10:40 +0800 Subject: [PATCH] ssl fix client and server passphrase handling again from "linedot" at https://github.com/warmcat/libwebsockets/issues/152#issuecomment-63647996 Signed-off-by: Andy Green --- lib/ssl.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ssl.c b/lib/ssl.c index 6a9f766..f3f1d18 100644 --- a/lib/ssl.c +++ b/lib/ssl.c @@ -58,7 +58,7 @@ static int lws_context_init_ssl_pem_passwd_cb(char * buf, int size, int rwflag, return strlen(buf); } -static void lws_ssl_bind_passphrase(struct libwebsocket_context *context, +static void lws_ssl_bind_passphrase(SSL_CTX *ssl_ctx, struct lws_context_creation_info *info) { if (!info->ssl_private_key_password) @@ -68,9 +68,8 @@ static void lws_ssl_bind_passphrase(struct libwebsocket_context *context, * for checking password which will be trigered during * SSL_CTX_use_PrivateKey_file function */ - SSL_CTX_set_default_passwd_cb_userdata(context->ssl_client_ctx, - (void *)info); - SSL_CTX_set_default_passwd_cb(context->ssl_client_ctx, + SSL_CTX_set_default_passwd_cb_userdata(ssl_ctx, (void *)info); + SSL_CTX_set_default_passwd_cb(ssl_ctx, lws_context_init_ssl_pem_passwd_cb); } @@ -183,7 +182,7 @@ lws_context_init_server_ssl(struct lws_context_creation_info *info, (char *)context->service_buffer)); return 1; } - lws_ssl_bind_passphrase(context, info); + lws_ssl_bind_passphrase(context->ssl_ctx, info); /* set the private key from KeyFile */ if (SSL_CTX_use_PrivateKey_file(context->ssl_ctx, info->ssl_private_key_filepath, @@ -346,7 +345,7 @@ int lws_context_init_client_ssl(struct lws_context_creation_info *info, } } if (info->ssl_private_key_filepath) { - lws_ssl_bind_passphrase(context, info); + lws_ssl_bind_passphrase(context->ssl_client_ctx, info); /* set the private key from KeyFile */ if (SSL_CTX_use_PrivateKey_file(context->ssl_client_ctx, info->ssl_private_key_filepath, SSL_FILETYPE_PEM) != 1) { -- 2.7.4