Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
bool done = false;

switch (reason) {
case LWS_CALLBACK_HTTP_CONFIRM_UPGRADE:
if (server->ssl && !lws_is_ssl(wsi)) {
lwsl_warn("refuse HTTP upgrade over non-SSL connection while SSL is enabled.\n");
return -1;
}
break;

case LWS_CALLBACK_HTTP:
access_log(wsi, (const char *)in);
snprintf(pss->path, sizeof(pss->path), "%s", (const char *)in);
Expand Down
1 change: 1 addition & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ int main(int argc, char **argv) {

#if defined(LWS_OPENSSL_SUPPORT) || defined(LWS_WITH_TLS)
if (ssl) {
server->ssl = true;
info.ssl_cert_filepath = cert_path;
info.ssl_private_key_filepath = key_path;
#ifndef LWS_WITH_MBEDTLS
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct server {
bool url_arg; // allow client to send cli arguments in URL
bool writable; // whether clients to write to the TTY
bool check_origin; // whether allow websocket connection from different origin
bool ssl; // whether SSL is enabled
int max_clients; // maximum clients to support
bool once; // whether accept only one client and exit on disconnection
bool exit_no_conn; // whether exit on all clients disconnection
Expand Down