From b04708178acf308a4416f2b264af85760f6219dc Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 20 Mar 2018 13:28:25 +0800 Subject: [PATCH] minimal: http-server-tls --- README.md | 13 +-- lib/tls/openssl/openssl-server.c | 2 +- .../minimal-ws-proxy/CMakeLists.txt | 13 +-- .../minimal-http-client/CMakeLists.txt | 14 +-- minimal-examples/http-server/README.md | 3 +- .../CMakeLists.txt | 13 +-- .../minimal-http-server-libuv/CMakeLists.txt | 13 +-- .../CMakeLists.txt | 14 +-- .../minimal-http-server-smp/CMakeLists.txt | 13 +-- .../minimal-http-server-tls/CMakeLists.txt | 78 ++++++++++++++++ .../minimal-http-server-tls/README.md | 45 ++++++++++ .../localhost-100y.cert | 34 +++++++ .../localhost-100y.key | 52 +++++++++++ .../minimal-http-server-tls.c | 84 ++++++++++++++++++ .../mount-origin/404.html | 9 ++ .../mount-origin/favicon.ico | Bin 0 -> 1406 bytes .../mount-origin/http2.png | Bin 0 -> 7563 bytes .../mount-origin/index.html | 39 ++++++++ .../mount-origin/libwebsockets.org-logo.png | Bin 0 -> 7029 bytes .../minimal-http-server/CMakeLists.txt | 14 +-- .../minimal-ws-client-rx/CMakeLists.txt | 13 +-- .../minimal-ws-client-tx/CMakeLists.txt | 13 +-- .../minimal-ws-broker/CMakeLists.txt | 14 +-- .../minimal-ws-server-pmd-bulk/CMakeLists.txt | 13 +-- .../minimal-ws-server-pmd/CMakeLists.txt | 13 +-- .../minimal-ws-server-ring/CMakeLists.txt | 13 +-- .../minimal-ws-server-threads/CMakeLists.txt | 13 +-- .../minimal-ws-server/CMakeLists.txt | 13 +-- 28 files changed, 458 insertions(+), 100 deletions(-) create mode 100644 minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt create mode 100644 minimal-examples/http-server/minimal-http-server-tls/README.md create mode 100644 minimal-examples/http-server/minimal-http-server-tls/localhost-100y.cert create mode 100644 minimal-examples/http-server/minimal-http-server-tls/localhost-100y.key create mode 100644 minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c create mode 100644 minimal-examples/http-server/minimal-http-server-tls/mount-origin/404.html create mode 100644 minimal-examples/http-server/minimal-http-server-tls/mount-origin/favicon.ico create mode 100644 minimal-examples/http-server/minimal-http-server-tls/mount-origin/http2.png create mode 100644 minimal-examples/http-server/minimal-http-server-tls/mount-origin/index.html create mode 100644 minimal-examples/http-server/minimal-http-server-tls/mount-origin/libwebsockets.org-logo.png diff --git a/README.md b/README.md index 851c5b98..0d60a88c 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,10 @@ News ## Lws has the first official ws-over-h2 server support -There's a new standard on the RFC track that enabled multiplexing ws connections +There's a new standard on the RFC track that enables multiplexing ws connections over an http/2 link. Compared to making individual tcp and tls connections for each ws link back to the same server, this makes your site start up radically -faster, and since all the connections are in one tls tunnel, with much memory +faster, and since all the connections are in one tls tunnel, with considerable memory reduction serverside. To enable it on master you just need -DLWS_WITH_HTTP2=1 at cmake. No changes to @@ -22,16 +22,17 @@ apis if you return your own headers, as shown in the test apps for several versi or to take advantage of ws-over-h2. When built with http/2 support, it automatically falls back to http/1 and traditional ws upgrade if that's all the client can handle. -Currently only Chrome Canary v67 supports this ws-over-h2 encapsulation but the other -browsers will catch up soon. +Currently only Chrome Canary v67 supports this ws-over-h2 encapsulation (chrome +must be started with `--enable-websocket-over-http2` switch to enable it currently) +but the other browsers will catch up soon. ## New "minimal examples" https://github.com/warmcat/libwebsockets/tree/master/minimal-examples -These are like the test apps, but focus on doing one thing, the best way, with the minimum amount of code. For example the minimal-http-server serves the cwd on http/1 or http/2 in 50 LOC. +These are like the test apps, but focus on doing one thing, the best way, with the minimum amount of code. For example the minimal-http-server serves the cwd on http/1 or http/2 in 50 LOC. Same thing with tls is just three more lines. -They also build standalone, so it's easier to copy them directly to start your own project; they +They build standalone, so it's easier to copy them directly to start your own project; they are CC0 licensed (public domain) to facilitate that. ## Windows binary builds diff --git a/lib/tls/openssl/openssl-server.c b/lib/tls/openssl/openssl-server.c index ab24af4c..0c7f8c92 100644 --- a/lib/tls/openssl/openssl-server.c +++ b/lib/tls/openssl/openssl-server.c @@ -280,7 +280,7 @@ check_key: if (extra_certs) x = sk_X509_value(extra_certs, 0); else - lwsl_err("%s: no extra certs\n", __func__); + lwsl_info("%s: no extra certs\n", __func__); #endif if (!x) { //lwsl_err("%s: x is NULL\n", __func__); diff --git a/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt b/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt index 006d260e..c3f7521c 100644 --- a/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt +++ b/minimal-examples/client-server/minimal-ws-proxy/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-proxy) set(SRCS minimal-ws-proxy.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt index 511362ed..f8b222cf 100644 --- a/minimal-examples/http-client/minimal-http-client/CMakeLists.txt +++ b/minimal-examples/http-client/minimal-http-client/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-http-client) set(SRCS minimal-http-client.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) @@ -61,6 +62,7 @@ MACRO(require_lws_config reqconfig _val result) endif() ENDMACRO() + set(requirements 1) require_lws_config(LWS_WITHOUT_CLIENT 0 requirements) diff --git a/minimal-examples/http-server/README.md b/minimal-examples/http-server/README.md index 59535d8e..034e89d8 100644 --- a/minimal-examples/http-server/README.md +++ b/minimal-examples/http-server/README.md @@ -1,6 +1,7 @@ |Example|Demonstrates| ---|--- -minimal-http-server|Serves a directory over http/1 or http/2, custom 404 handler +minimal-http-server|Serves a directory over http/1, custom 404 handler +minimal-http-server-tls|Serves a directory over http/1 or http/2 with TLS (SSL), custom 404 handler minimal-http-server-libuv|Same as minimal-http-server but libuv event loop minimal-http-server-multivhost|Same as minimal-http-server but three different vhosts minimal-http-server-smp|Multiple service threads diff --git a/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt index 2943e46f..3286a419 100644 --- a/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-dynamic/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-http-server-dynamic) set(SRCS minimal-http-server-dynamic.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/http-server/minimal-http-server-libuv/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-libuv/CMakeLists.txt index 3a2a0e5a..dc56dcdd 100644 --- a/minimal-examples/http-server/minimal-http-server-libuv/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-libuv/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-http-server-libuv) set(SRCS minimal-http-server.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt index 5684ff2f..ae0400dd 100644 --- a/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-multivhost/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-http-server-multivhost) set(SRCS minimal-http-server.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) @@ -60,7 +61,6 @@ MACRO(require_lws_config reqconfig _val result) endif() ENDMACRO() - set(requirements 1) require_lws_config(LWS_WITHOUT_SERVER 0 requirements) diff --git a/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt index 59f49b75..fedd1550 100644 --- a/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt +++ b/minimal-examples/http-server/minimal-http-server-smp/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-http-server-smp) set(SRCS minimal-http-server-smp.c) @@ -51,16 +51,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt b/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt new file mode 100644 index 00000000..7c8e7d62 --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/CMakeLists.txt @@ -0,0 +1,78 @@ +cmake_minimum_required(VERSION 2.8) +include(CheckCSourceCompiles) + +set(SAMP lws-minimal-http-server-tls) +set(SRCS minimal-http-server-tls.c) + +# If we are being built as part of lws, confirm current build config supports +# reqconfig, else skip building ourselves. +# +# If we are being built externally, confirm installed lws was configured to +# support reqconfig, else error out with a helpful message about the problem. +# +MACRO(require_lws_config reqconfig _val result) + + if (DEFINED ${reqconfig}) + if (${reqconfig}) + set (rq 1) + else() + set (rq 0) + endif() + else() + set(rq 0) + endif() + + if (${_val} EQUAL ${rq}) + set(SAME 1) + else() + set(SAME 0) + endif() + + if (LWS_WITH_MINIMAL_EXAMPLES AND NOT ${SAME}) + if (${_val}) + message("${SAMP}: skipping as lws being built without ${reqconfig}") + else() + message("${SAMP}: skipping as lws built with ${reqconfig}") + endif() + set(${result} 0) + else() + if (LWS_WITH_MINIMAL_EXAMPLES) + set(MET ${SAME}) + else() + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) + endif() + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) + set(MET 1) + else() + set(MET 0) + endif() + endif() + if (NOT MET) + if (${_val}) + message(FATAL_ERROR "This project requires lws must have been configured with ${reqconfig}") + else() + message(FATAL_ERROR "Lws configuration of ${reqconfig} is incompatible with this project") + endif() + endif() + + endif() +ENDMACRO() + +set(requirements 1) +require_lws_config(LWS_WITHOUT_SERVER 0 requirements) +require_lws_config(LWS_OPENSSL_SUPPORT 1 requirements) + +if (requirements) + add_executable(${SAMP} ${SRCS}) + + if (websockets_shared) + target_link_libraries(${SAMP} websockets_shared) + add_dependencies(${SAMP} websockets_shared) + else() + target_link_libraries(${SAMP} websockets) + endif() +endif() diff --git a/minimal-examples/http-server/minimal-http-server-tls/README.md b/minimal-examples/http-server/minimal-http-server-tls/README.md new file mode 100644 index 00000000..b10ffed6 --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/README.md @@ -0,0 +1,45 @@ +# lws minimal http server with tls + +## build + +``` + $ cmake . && make +``` + +## usage + +``` + $ ./lws-minimal-http-server-tls +[2018/03/20 13:23:13:0131] USER: LWS minimal http server TLS | visit https://localhost:7681 +[2018/03/20 13:23:13:0142] NOTICE: Creating Vhost 'default' port 7681, 1 protocols, IPv6 off +[2018/03/20 13:23:13:0142] NOTICE: Using SSL mode +[2018/03/20 13:23:13:0146] NOTICE: SSL ECDH curve 'prime256v1' +[2018/03/20 13:23:13:0146] NOTICE: HTTP2 / ALPN enabled +[2018/03/20 13:23:13:0195] NOTICE: lws_tls_client_create_vhost_context: doing cert filepath localhost-100y.cert +[2018/03/20 13:23:13:0195] NOTICE: Loaded client cert localhost-100y.cert +[2018/03/20 13:23:13:0195] NOTICE: lws_tls_client_create_vhost_context: doing private key filepath +[2018/03/20 13:23:13:0196] NOTICE: Loaded client cert private key localhost-100y.key +[2018/03/20 13:23:13:0196] NOTICE: created client ssl context for default +[2018/03/20 13:23:14:0207] NOTICE: vhost default: cert expiry: 730459d +``` + +Visit https://localhost:7681 + +Because it uses a selfsigned certificate, you will have to make an exception for it in your browser. + +## Certificate creation + +The selfsigned certs provided were created with + +``` +echo -e "GB\nErewhon\nAll around\nlibwebsockets-test\n\nlocalhost\nnone@invalid.org\n" | openssl req -new -newkey rsa:4096 -days 36500 -nodes -x509 -keyout "localhost-100y.key" -out "localhost-100y.cert" +``` + +they cover "localhost" and last 100 years from 2018-03-20. + +You can replace them with commercial certificates matching your hostname. + +## HTTP/2 + +If you built lws with `-DLWS_WITH_HTTP2=1` at cmake, this simple server is also http/2 capable +out of the box. If the index.html was loaded over http/2, it will display an HTTP 2 png. diff --git a/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.cert b/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.cert new file mode 100644 index 00000000..6f372db4 --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.cert @@ -0,0 +1,34 @@ +-----BEGIN CERTIFICATE----- +MIIF5jCCA86gAwIBAgIJANq50IuwPFKgMA0GCSqGSIb3DQEBCwUAMIGGMQswCQYD +VQQGEwJHQjE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TYSAZWl+IssmXjefxJqYi2/7QWmv1QC9p +sNcjTMaBQLN03T1Qelbs7Y27sxdEnNUth4kI+wIDAQABo1MwUTAdBgNVHQ4EFgQU +9mYU23tW2zsomkKTAXarjr2vjuswHwYDVR0jBBgwFoAU9mYU23tW2zsomkKTAXar +jr2vjuswDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEANjIBMrow +YNCbhAJdP7dhlhT2RUFRdeRUJD0IxrH/hkvb6myHHnK8nOYezFPjUlmRKUgNEDuA +xbnXZzPdCRNV9V2mShbXvCyiDY7WCQE2Bn44z26O0uWVk+7DNNLH9BnkwUtOnM9P +wtmD9phWexm4q2GnTsiL6Ul6cy0QlTJWKVLEUQQ6yda582e23J1AXqtqFcpfoE34 +H3afEiGy882b+ZBiwkeV+oq6XVF8sFyr9zYrv9CvWTYlkpTQfLTZSsgPdEHYVcjv +xQ2D+XyDR0aRLRlvxUa9dHGFHLICG34Juq5Ai6lM1EsoD8HSsJpMcmrH7MWw2cKk +ujC3rMdFTtte83wF1uuF4FjUC72+SmcQN7A386BC/nk2TTsJawTDzqwOu/VdZv2g +1WpTHlumlClZeP+G/jkSyDwqNnTu1aodDmUa4xZodfhP1HWPwUKFcq8oQr148QYA +AOlbUOJQU7QwRWd1VbnwhDtQWXC92A2w1n/xkZSR1BM/NUSDhkBSUU1WjMbWg6Gg +mnIZLRerQCu1Oozr87rOQqQakPkyt8BUSNK3K42j2qcfhAONdRl8Hq8Qs5pupy+s +8sdCGDlwR3JNCMv6u48OK87F4mcIxhkSefFJUFII25pCGN5WtE4p5l+9cnO1GrIX +e2Hl/7M0c/lbZ4FvXgARlex2rkgS0Ka06HE= +-----END CERTIFICATE----- diff --git a/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.key b/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.key new file mode 100644 index 00000000..148f8598 --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/localhost-100y.key @@ -0,0 +1,52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1taBZZogRqI3rOkkPk= +-----END PRIVATE KEY----- diff --git a/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c new file mode 100644 index 00000000..7afd0ffd --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/minimal-http-server-tls.c @@ -0,0 +1,84 @@ +/* + * lws-minimal-http-server-tls + * + * Copyright (C) 2018 Andy Green + * + * This file is made available under the Creative Commons CC0 1.0 + * Universal Public Domain Dedication. + * + * This demonstrates the most minimal http server you can make with lws, + * with three extra lines giving it tls (ssl) capabilities, which in + * turn allow operation with HTTP/2 if lws was configured for it. + * + * To keep it simple, it serves stuff from the subdirectory + * "./mount-origin" of the directory it was started in. + * + * You can change that by changing mount.origin below. + */ + +#include +#include +#include + +static int interrupted; + +static const struct lws_http_mount mount = { + /* .mount_next */ NULL, /* linked-list "next" */ + /* .mountpoint */ "/", /* mountpoint URL */ + /* .origin */ "./mount-origin", /* serve from dir */ + /* .def */ "index.html", /* default filename */ + /* .protocol */ NULL, + /* .cgienv */ NULL, + /* .extra_mimetypes */ NULL, + /* .interpret */ NULL, + /* .cgi_timeout */ 0, + /* .cache_max_age */ 0, + /* .auth_mask */ 0, + /* .cache_reusable */ 0, + /* .cache_revalidate */ 0, + /* .cache_intermediaries */ 0, + /* .origin_protocol */ LWSMPRO_FILE, /* files in a dir */ + /* .mountpoint_len */ 1, /* char count */ + /* .basic_auth_login_file */ NULL, +}; + +void sigint_handler(int sig) +{ + interrupted = 1; +} + +int main(int argc, char **argv) +{ + struct lws_context_creation_info info; + struct lws_context *context; + int n = 0; + + signal(SIGINT, sigint_handler); + + memset(&info, 0, sizeof info); /* otherwise uninitialized garbage */ + info.port = 7681; + info.mounts = &mount; + info.error_document_404 = "/404.html"; + + info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT; + info.ssl_cert_filepath = "localhost-100y.cert"; + info.ssl_private_key_filepath = "localhost-100y.key"; + + lws_set_log_level(LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_USER + /* | LLL_INFO */ /* | LLL_DEBUG */, NULL); + + lwsl_user("LWS minimal http server TLS | visit https://localhost:7681\n"); + + context = lws_create_context(&info); + if (!context) { + lwsl_err("lws init failed\n"); + return 1; + } + + while (n >= 0 && !interrupted) + n = lws_service(context, 1000); + + lws_context_destroy(context); + + return 0; +} diff --git a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/404.html b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/404.html new file mode 100644 index 00000000..1f7ae66e --- /dev/null +++ b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/404.html @@ -0,0 +1,9 @@ + + + +
+

404

+ Sorry, that file doesn't exist. + + + diff --git a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/favicon.ico b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c0cc2e3dff34012ba3d4a7848a7ed17579788ec5 GIT binary patch literal 1406 zcmZQzU<5(|0R}M0U}azs1F|%L7$l?s#Ec9aKoZP=&`9i!<^REA8>%80(yxAC$j<-A zkb5S8;qL6446ipNFl>5#fuVR6L=8goC~GtXMnhmYga9MSfQgBTk&TUw5$JocUP63y z3phA97+G0a8QIy{!BT|y==xb$SQt4uIT@LmnZZ(o_~`mk`Tv1M8w?+DXJCL~kQj^& JqOtKoVgQl$ETjMc literal 0 HcmV?d00001 diff --git a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/http2.png b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/http2.png new file mode 100644 index 0000000000000000000000000000000000000000..439bfa482fa00e69af2d562f17a6e89453eb98cc GIT binary patch literal 7563 zcmV;69dzP}P)hJCKl}1r-pgb%At50^h&s(NL+gbgh*}K=@24(BV^6&tYNdLrZS7HN zyRhvft=8kJ)}>`BinW|B6&C>(SXZ@*0u?HyMyuE;F`57gnPfs{=FNL~F8gx+c%FA| z?>m_n2rSNOzH7~znf?5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XWl zw2M!b?R%i&=I8F^S_*}wl{ z-@eZJk&)BlN~MO@3dr)~#~*1XNyipnN7mxFGL<9^oMZjaP;ty{wOU8Y2xHnLNrxz^ zmVSi@5ajuB($t`oL+gkz9Kzb7;=9=RELoNlhCwNgDP7%BDT-sjk!3A}5U$;B<;D;x zHMDPLW-;748u%hnWzj6xlHRkedG}xYaME>M@*V_b%r=s$_rzZ*V@V~TR{+XLLrVR z=Q87cV2n{(%20-34$!pL$IfLg46XJ)Aj{f`QbH9cMaDvFDa#@bp;Si%fs~LqYopwI z8Cly&tJUeq+U!85lWjS4$cpXTdwhZ?mS5Yq%R4}B9UGJTTPhmZZtJ}1wQFiht{oZCL6S%}GUB^Nh^$nK1im;H05cO4dA4p{&$Jwyn(}Pg z + + +
+ + Hello from the minimal https server example. +
+ You can confirm the 404 page handler by going to this + nonexistant page. +
+
+ + + + + diff --git a/minimal-examples/http-server/minimal-http-server-tls/mount-origin/libwebsockets.org-logo.png b/minimal-examples/http-server/minimal-http-server-tls/mount-origin/libwebsockets.org-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..2060a10c936a0959f2a5c3a6b7fa60ac324f1a95 GIT binary patch literal 7029 zcmbVRWmpqlxM!r~7}7Nyl2W6Q#v!1jW1y7e=5vh%{0%8YD%LA&rz{ z3?wCl%l&#k-rw__{GIbY=Xu}r;f-WdV?9PXZaOkDGDZV^*dsDBfa>-9-VN&O{@2fU zOVHE6PdLE9; zwCw2SDGEMdM?5}xT(d`%!9}ww_d_}SY|s@~)J&Gs?w%cw{+D1n(nf{~ou>LQ$=tw$ zIRQ}=7o5sn_dVG`ATwXna@P>Z6nhwWi}ODz#Pm|TGC2cP4S=0o6-y{bh&G5!!V!a( ziW%2WZF|wC(V&_Tbzcei$pB`RGDLx!#(86iH43%SY$G;ce81GtXfDkZML!owkES2W8W*DJo^ zm%s0OovL=+Z*Im!aqRDq5+|piUaUX|atGK@y}>3@{Pd0UjypF$>aq)ax~#wKjp%Hr zuCm@?MyJI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{_BdJJG2IXFE*TW6xt7P`sO~KF>Opa-4)+zwxPucUd{zOcf7j zs`1bAuuSUYbRV2nPcFO&hMo>yxY#OL3^acbmJ)a1u}%q&25%8aA`T_oadHPdz!F`pbm^} zy!T&=eM3)lyh-Pt?xzOf+T?q(`qdOsJ3Z$V(vj{FWG3a`uV%6W*4(5n>-YErv6Z;= z#Vf9w%V_Avg7{Fmm@t#dY-GrSt;Qv^P%v|soaeUQ^zr#q5@KAoS(?o?fxgaZ^^)-1 zRvg0NPz0hI`-19uFUbf0{YF;-GNwLC=0$j;^Ks!JCY! zFZmnOmEw<+BR8;ZS}^uZRp6@aQHMy%&~EMQ$sDKPp^>VHr>@+%CVA{&qlj@&f%f-1 zS-nJ^vOln%tv-gMc6;i9SZ1^sW-vvEVK?YU)Qd3|ba90T;TFHA*dlq`OZ~tT&Er#Sc@k zF}EQNFlXjT7$Q2!PTG{IfgUKwMI!*AfM(qObfs>7Brn3sue*~M7))6d%&=SXu5O0B zf)EPXw_G+TPpSoeC4@~n=&cjd z{8ObRGje1y26@_LHTx9}tN^a|#s8%uzk)_r4~x7KrSgeu&T-LC^RigV8G_fr)P;k3CQOPTrc~vIx9DfT z`nbZYT|ubgJb1E9PkM>~RqMDKHoUO%GF_l{Vp)K;K4zEdUCWk?^Oko_4wN7G z#MH-xdN5yYGJuTLs0rRN`qF{xp99ZfxRQoX{jMekvj2X36^Q;!zL~U`d^0AMQJA7O zEx)?t1{hb=eJ16jO3eCH-JEnXQY&=gf)@z=h%H)m`!?KSsLVT;il=p28%7Sygx%!4 zw%VPzNI8Oei&=UckW\nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) @@ -61,6 +62,7 @@ MACRO(require_lws_config reqconfig _val result) endif() ENDMACRO() + set(requirements 1) require_lws_config(LWS_WITHOUT_SERVER 0 requirements) diff --git a/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt index 22f69014..9548db3c 100644 --- a/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-rx/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-client-rx) set(SRCS minimal-ws-client.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt b/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt index 156d7c35..a43e3dc6 100644 --- a/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt +++ b/minimal-examples/ws-client/minimal-ws-client-tx/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-client-tx) set(SRCS minimal-ws-client.c) @@ -50,16 +50,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt index 8ad44309..73fb25a8 100644 --- a/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-broker/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-broker) set(SRCS minimal-ws-broker.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) @@ -60,7 +61,6 @@ MACRO(require_lws_config reqconfig _val result) endif() ENDMACRO() - set(requirements 1) require_lws_config(LWS_WITHOUT_SERVER 0 requirements) diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt index 36af4b78..82b70652 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-pmd-bulk/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8.9) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-server-pmd-bulk) set(SRCS minimal-ws-server-pmd-bulk.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt index 8b9721b1..fb607abf 100644 --- a/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-pmd/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8.9) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-server-pmd) set(SRCS minimal-ws-server-pmd.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt index 04e9d5bd..01445cf0 100644 --- a/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-ring/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-server-ring) set(SRCS minimal-ws-server.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt index 8b147749..4f232053 100644 --- a/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server-threads/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 2.8) include(CheckIncludeFile) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-server-threads) set(SRCS minimal-ws-server.c) @@ -51,16 +51,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val}) diff --git a/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt b/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt index 6ec72fe9..c0cb7cbc 100644 --- a/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt +++ b/minimal-examples/ws-server/minimal-ws-server/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) -include(CheckSymbolExists) +include(CheckCSourceCompiles) set(SAMP lws-minimal-ws-server) set(SRCS minimal-ws-server.c) @@ -39,16 +39,17 @@ MACRO(require_lws_config reqconfig _val result) if (LWS_WITH_MINIMAL_EXAMPLES) set(MET ${SAME}) else() - CHECK_SYMBOL_EXISTS(${reqconfig} libwebsockets.h HAS) - if (NOT DEFINED HAS) - set(HAS 0) + CHECK_C_SOURCE_COMPILES("#include \nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig}) + if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig}) + set(HAS_${reqconfig} 0) + else() + set(HAS_${reqconfig} 1) endif() - if ((HAS AND ${_val}) OR (NOT HAS AND NOT ${_val})) + if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val})) set(MET 1) else() set(MET 0) endif() - endif() if (NOT MET) if (${_val})