1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Fixed the logging of OpenSSL errors to report the correct details for the current OpenSSL error

This commit is contained in:
Jonti 2013-11-22 13:14:26 +02:00
parent 909a3720c7
commit f7e7936c78
2 changed files with 23 additions and 17 deletions

View file

@ -207,8 +207,8 @@ int lws_client_socket_service(struct libwebsocket_context *context,
n = ERR_get_error();
if (n != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
n,
ERR_error_string(n,
(char *)context->service_buffer));
return 0;
}
@ -267,8 +267,8 @@ int lws_client_socket_service(struct libwebsocket_context *context,
n = ERR_get_error();
if (n != SSL_ERROR_NONE) {
lwsl_err("SSL connect error %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
n,
ERR_error_string(n,
(char *)context->service_buffer));
return 0;
}

View file

@ -1980,18 +1980,20 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
method = (SSL_METHOD *)SSLv23_server_method();
if (!method) {
int error = ERR_get_error();
lwsl_err("problem creating ssl method %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}
context->ssl_ctx = SSL_CTX_new(method); /* create context */
if (!context->ssl_ctx) {
int error = ERR_get_error();
lwsl_err("problem creating ssl context %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
(char *)context->service_buffer));
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}
@ -2010,18 +2012,20 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
if (info->port == CONTEXT_PORT_NO_LISTEN) {
method = (SSL_METHOD *)SSLv23_client_method();
if (!method) {
int error = ERR_get_error();
lwsl_err("problem creating ssl method %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}
/* create context */
context->ssl_client_ctx = SSL_CTX_new(method);
if (!context->ssl_client_ctx) {
int error = ERR_get_error();
lwsl_err("problem creating ssl context %lu: %s\n",
ERR_get_error(),
ERR_error_string(ERR_get_error(),
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}
@ -2095,10 +2099,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
n = SSL_CTX_use_certificate_chain_file(context->ssl_ctx,
info->ssl_cert_filepath);
if (n != 1) {
int error = ERR_get_error();
lwsl_err("problem getting cert '%s' %lu: %s\n",
info->ssl_cert_filepath,
ERR_get_error(),
ERR_error_string(ERR_get_error(),
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}
@ -2106,10 +2111,11 @@ libwebsocket_create_context(struct lws_context_creation_info *info)
if (SSL_CTX_use_PrivateKey_file(context->ssl_ctx,
info->ssl_private_key_filepath,
SSL_FILETYPE_PEM) != 1) {
int error = ERR_get_error();
lwsl_err("ssl problem getting key '%s' %lu: %s\n",
info->ssl_private_key_filepath,
ERR_get_error(),
ERR_error_string(ERR_get_error(),
error,
ERR_error_string(error,
(char *)context->service_buffer));
goto bail;
}