add lws_is_ssl api

Suggested by Michael Harbler on the mailing list

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2014-08-16 09:54:27 +08:00
parent 95a8abb030
commit b128ccccca
3 changed files with 22 additions and 0 deletions

View file

@ -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
=======================

View file

@ -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;
}

View file

@ -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);