From 6b5c1af4393413db0666becf41f60dbc810982a7 Mon Sep 17 00:00:00 2001 From: shys Date: Fri, 25 Oct 2013 15:52:47 +0200 Subject: [PATCH] Subject: [PATCH] On iOS with nonblocking sockets I experience SSL error which is not really an error ( http://lists.freeradius.org/pipermail/freeradius-users/2009-August/040155.html ). Added check for that. Additional fixes for comments and logging. --- lib/client.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/client.c b/lib/client.c index c81f6413..561c009f 100644 --- a/lib/client.c +++ b/lib/client.c @@ -196,16 +196,21 @@ int lws_client_socket_service(struct libwebsocket_context *context, * retry if new data comes until we * run into the connection timeout or win */ - - lwsl_err("SSL connect error %lu: %s\n", - ERR_get_error(), - ERR_error_string(ERR_get_error(), - (char *)context->service_buffer)); - return 0; + + 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(), + (char *)context->service_buffer)); + return 0; + } } } else wsi->ssl = NULL; + /* fallthru */ + case LWS_CONNMODE_WS_CLIENT_WAITING_SSL: if (wsi->use_ssl) { @@ -214,7 +219,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, lws_latency_pre(context, wsi); n = SSL_connect(wsi->ssl); lws_latency(context, wsi, - "SSL_connect LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE", + "SSL_connect LWS_CONNMODE_WS_CLIENT_WAITING_SSL", n, n > 0); if (n < 0) { @@ -252,12 +257,14 @@ int lws_client_socket_service(struct libwebsocket_context *context, * retry if new data comes until we * run into the connection timeout or win */ - - lwsl_err("SSL connect error %lu: %s\n", - ERR_get_error(), - ERR_error_string(ERR_get_error(), - (char *)context->service_buffer)); - return 0; + 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(), + (char *)context->service_buffer)); + return 0; + } } }