diff --git a/changelog b/changelog index 1652fe8f..8e592251 100644 --- a/changelog +++ b/changelog @@ -16,6 +16,11 @@ be used by the user code to mark the selected protocol by user-defined version or capabliity flag information, for the case multiple versions of a protocol are supported. +int lws_is_ssl(wsi) added to allow user code to know if the connection was made +over ssl or not. If LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT is used, both +ssl and non-ssl connections are possible and may need to be treated differently +in the user code. + v1.3-chrome37-firefox30 ======================= diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index ee88e2e1..a5ec698b 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -755,3 +755,17 @@ LWS_VISIBLE void lws_set_log_level(int level, void (*log_emit_function)(int leve if (log_emit_function) lwsl_emit = log_emit_function; } + +/** + * lws_use_ssl() - Find out if connection is using SSL + * @wsi: websocket connection to check + * + * Returns 0 if the connection is not using SSL, 1 if using SSL and + * using verified cert, and 2 if using SSL but the cert was not + * checked (appears for client wsi told to skip check on connection) + */ +LWS_VISIBLE int +lws_is_ssl(struct libwebsocket *wsi) +{ + return wsi->use_ssl; +} diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h index e6cc2a05..3cd5b597 100644 --- a/lib/libwebsockets.h +++ b/lib/libwebsockets.h @@ -1181,6 +1181,9 @@ lws_send_pipe_choked(struct libwebsocket *wsi); LWS_VISIBLE LWS_EXTERN int lws_frame_is_binary(struct libwebsocket *wsi); +LWS_VISIBLE LWS_EXTERN int +lws_is_ssl(struct libwebsocket *wsi); + LWS_VISIBLE LWS_EXTERN unsigned char * libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);