1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

357 commits

Author SHA1 Message Date
Andy Green
30e6c22e14 openssl3: migrate genhmac to EVP
The low level apis for HMAC (including those only introduced at 1.1.0...)
are all deprecated in OpenSSL v3.

Let's bite the bullet and migrate to EVP, it's already existing in modern
OpenSSL and we already use it for genhash.

EVP needs a PKEY, sort that out and keep it around until the hmac is
destroyed.
2020-06-16 19:45:35 +01:00
Andy Green
2a772776a9 windows: for data exports use explicit extern
LWS_EXTERN needs to be empty for windows when declaring functions in the
headers.  But for data, it needs the explicit extern otherwise on windows
or mingw based builds, it thinks we are redeclaring the data each time.
2020-06-07 07:53:36 +01:00
Andy Green
f0c1ea801c mingw: fix for different sockfd type in udp example
As found by Sai
2020-06-06 15:53:58 +01:00
alex
5d514b35fc tls: add read client .pem or .der from memory #1941
and added read private key from mem
2020-06-06 13:09:31 +01:00
Andy Green
c0294c3e10 clean: use lws_intptr_t where needed 2020-06-03 06:48:06 +01:00
Andy Green
286cf4357a sul: multiple timer domains
Adapt the pt sul owner list to be an array, and define two different lists,
one that acts like before and is the default for existing users, and another
that has the ability to cooperate with systemwide suspend to restrict the
interval spent suspended so that it will wake in time for the earliest
thing on this wake-suspend sul list.

Clean the api a bit and add lws_sul_cancel() that only needs the sul as the
argument.

Add a flag for client creation info to indicate that this client connection
is important enough that, eg, validity checking it to detect silently dead
connections should go on the wake-suspend sul list.  That flag is exposed in
secure streams policy so it can be added to a streamtype with
"swake_validity": true

Deprecate out the old vhost timer stuff that predates sul.  Add a flag
LWS_WITH_DEPRECATED_THINGS in cmake so users can get it back temporarily
before it will be removed in a v4.2.

Adapt all remaining in-tree users of it to use explicit suls.
2020-06-02 08:37:10 +01:00
Andy Green
d5773c01be openssl-v3: deal with deprecated SSL_CTX_load_verify_locations
Add Sai for openssl-v3 and for boringssl
2020-06-02 08:37:10 +01:00
Andy Green
f98e4a845c sai: add f32 plus openssl-v3 combination 2020-06-02 08:37:10 +01:00
Andy Green
911898ad70 windows: recent win10 support Unix Domain
Allow selection of Unix Domain Sockets on windows since it is supported
for the last couple of years on windows 10

https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

... if only they could add a full set of posix pieces to go with it
(and abstract namespace UDS which doesn't work apparently) so that
the parts dealing with uid / gid don't have to be disabled.
2020-06-02 08:37:10 +01:00
Seonah Moon
b6e215ee7f openssl: fix improper use of negative value 2020-06-02 08:37:10 +01:00
Andy Green
10146575a2 clean: turn down verbosity on some debugging printfs 2020-06-02 08:37:10 +01:00
Andy Green
b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
Andy Green
cabe021955 esp32: shift to support latest esp-idf
Esp-idf has an improved but still kind of abused cmake-
based build system now.

If we see ESP_PLATFORM coming as a cmake var, we can know we
are being built from inside the esp-idf config system.

Leave the existing esp32 arrangements alone but triggered off
ESP_PLATFORM, adapt to use the cross toolchain file and
various quirks automatically.

In this way you can build lws a part of your project in a
much cleaner way.

Prepare a minimal esp32 test app for use in Sai

Adapt .sai.json to build for esp32
2020-05-27 08:40:12 +01:00
Andy Green
33f8e219eb tls: defer listing of pending tls wsi to be managed by tls read only
https://github.com/warmcat/libwebsockets/issues/1920
2020-05-27 08:40:12 +01:00
Andy Green
9f1d019352 CTest: migrate and deprecate existing selftest scripts
Replace the bash selftest plumbing with CTest.

To use the selftests, build with -DLWS_WITH_MINIMAL_EXAMPLES=1
and `CTEST_OUTPUT_ON_FAILURE=1 make test` or just
`make test`.

To disable tests that require internet access, also give
-DLWS_CTEST_INTERNET_AVAILABLE=0

Remove travis and appveyor scripts on master.

Remove travis and appveyor decals on README.md.
2020-05-11 15:40:13 +01:00
Steve Kyoungwon Kim
a9275d8dea BoringSSL: provide X509_VERYFY_PARAM_Set1_host length
X509_VERYFY_PARAM_Set1_host of openSSL allows the third argument, which
is the length of the hostname string, to be 0. Then, it assumes hostname
is a null-terminated C string. BoringSSL enforces the actual length to
be specified, and the hostname string should end with a null char.

Just provide the length, making both OpenSSL and BoringSSL happy.
2020-04-30 05:20:29 +01:00
Andy Green
d9f793ae12 logs: allow giving log bitfields from cmake to force build or exclusion
By default this doesn't change any existing logging behaviour at all.

But it allows you to define cmake options to force or force-disable the
build of individual log levels using new cmake option bitfields
LWS_LOGGING_BITFIELD_SET and LWS_LOGGING_BITFIELD_CLEAR.

Eg, -DLWS_LOGGING_BITFIELD_SET="(LLL_INFO)" can force INFO log level
built even in release mode.  -DLWS_LOGGING_BITFIELD_CLEAR="(LLL_NOTICE)"
will likewise remove NOTICE logging from the build regardless of
DEBUG or RELEASE mode.
2020-04-22 06:59:01 +01:00
Andy Green
a57e62d502 ctest: fixes-and-changes 2020-04-19 08:43:01 +01:00
Andy Green
e4c59e3a91 osx: mbedtls: SYSCALL and errno 35 is WANT_READ 2020-04-17 12:39:53 +01:00
Andy Green
e3d780dac6 gencrypto: windows: warnings
Coming out of increasing number of build variants on windows via Sai
2020-04-12 08:39:27 +01:00
Andy Green
39b05e7db3 mbedtls: remove mbedtls_x509_crt_info reference
Nobody uses this from the wrapper... it brings in mbedtls_x509_crt_info()
even if you're using -ffunctionsections for a loss of about 1.7KB on Arm.


Let's chop it out...
2020-03-31 11:36:47 +01:00
Andy Green
be32d0554e mbedtls: attempt to remove dependency on net_sockets.c
The mbedtls openssl wrapper wants to use exports from mbedtls' net_sockets.c,
but this is only supposed to work on *nix and windows.  Typically people
are using mbedtls on RTOS type platforms and to use it, net_sockets.c
needs some hacking.

Try to avoid that situation by porting the two exports we need into the
lws plat code and call from the wrapper.
2020-03-27 13:24:44 +00:00
Andy Green
2a7a92f4d5 mbedtls: support old 2.2-era version from xenial 2020-03-21 14:43:53 +00:00
Akira Tsukamoto
47ea968e16 jws: lws_gencrypto_jws_alg_to_definition needs sentinel
Otherwise segfault when end of array reached.
2020-03-21 14:43:53 +00:00
Andy Green
5c657e0865 wolfssl: build fixes
Solve wolfssl wrappers being defines and header path availability for cmake tests
2020-03-20 09:35:54 +00:00
Andy Green
11837db0e0 mbedtls: support older versions without net_sockets.h 2020-03-19 10:14:25 +00:00
Andy Green
5b9fe01863 build: release mode compile fixes 2020-03-10 06:45:24 +00:00
Andy Green
7efe93bb34 fallback: dont check after first ssl accept attempt 2020-03-06 10:18:43 +00:00
Andy Green
c25c37febd client: make sure all paths after connect go via tls if set 2020-03-04 12:17:49 +00:00
Andy Green
28ce32af64 client: secure streams
Secure Streams is an optional layer on top of lws that separates policy
like endpoint selection and tls cert validation into a device JSON
policy document.

Code that wants to open a client connection just specifies a streamtype name,
and no longer deals with details like the endpoint, the protocol (!) or anything
else other than payloads and optionally generic metadata; the JSON policy
contains all the details for each streamtype.  h1, h2, ws and mqtt client
connections are supported.

Logical secure streams outlive any particular connection and supports "nailed-up"
connectivity regardless of underlying connection stability.
2020-03-04 12:17:49 +00:00
Andy Green
bb1a8d37fb rtos diet: make basic auth support a config option on by default
Remove wrapper content for < tls v1.2
2020-03-04 11:00:04 +00:00
Andy Green
3c663da99e rtos diet: mbedtls: wrapper: delete unused functions
Surprisingly -fdata-sections -ffunction-sections does not remove any string literals and __func__
implicit .rodata generated by the removed function's compilation.

That means potentially considerable deadweight is in the image even if the function is removed
at linktime.
2020-03-04 11:00:04 +00:00
Andy Green
0dd23d7073 tls restriction: account for pipelining and add test 2020-03-01 08:14:43 +00:00
dzakarias
3d8fbdd3ac Added missing PKCS#7 padding/unpadding from AES-CBC in JWE 2020-02-21 17:32:41 +00:00
Andy Green
ac1229f2f7 minimal-http-client-multi: add POST
This adds support for POST in both h1 and h2 queues / stream binding.

The previous queueing tried to keep the "leader" wsi who made the
actual connection around and have it act on the transaction queue
tail if it had done its own thing.

This refactors it so instead, who is the "leader" moves down the
queue and the queued guys inherit the fd, SSL * and queue from the
old leader as they take over.

This lets them operate in their own wsi identity directly and gets
rid of all the "effective wsi" checks, which was applied incompletely
and getting out of hand considering the separate lws_mux checks for
h2 and other muxed protocols alongside it.

This change also allows one wsi at a time to own the transaction for
POST.  --post is added as an option to lws-minimal-http-client-multi
and 6 extra selftests with POST on h1/h2, pipelined or not and
staggered or not are added to the CI.
2020-02-21 17:32:41 +00:00
Andy Green
329adcfbba openssl: disallow client connections if X509_VERIFY_PARAM_set1_host absent from tls lib
https://github.com/warmcat/libwebsockets/issues/1827
2020-01-17 07:45:35 +00:00
Andy Green
66b2a4a645 tls: apply restriction if any also to client connections 2020-01-15 16:32:48 +00:00
Andy Green
157acfc906 windows: clean type warnings
There are some minor public api type improvements rather than cast everywhere
inside lws and user code to work around them... these changed from int to
size_t

 - lws_buflist_use_segment() return
 - lws_tokenize_t .len and .token_len
 - lws_tokenize_cstr() length
 - lws_get_peer_simple() namelen
 - lws_get_peer_simple_fd() namelen, int fd -> lws_sockfd_type fd
 - lws_write_numeric_address() len
 - lws_sa46_write_numeric_address() len

These changes are typically a NOP for user code
2020-01-11 14:04:50 +00:00
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +00:00
Wojtek Kaniewski
ea50c8722c openssl: handle negotiation errors handling in client
If a client connects to a SSL server and the server sends handshake
alert (e.g. no matching ciphers) SSL_connect() fails, but because
SSL_ERROR_SSL return value is not handled, it's not considered a
failure. SSL_want_read() will return 1 and the client will happily wait
for more data from the server. Now if the server closes connection after
sending handshake alert, POLLIN event will be triggered,
lws_tls_client_connect() called again, but SSL_connect() will fail
without calling read(), so the client will end up consuming 100% CPU
because POLLIN will be triggered repeatedly.

Similar error handling is used in lws_tls_server_accept() and the
condition checks for SSL_ERROR_SSL. Using the same condition in
lws_tls_client_connect() fixes the problem.

Tested with OpenSSL 1.0.2k.
2019-12-19 21:30:09 +00:00
Andy Green
2eeec91d3d tls: lws_system per-connection client certs
Now the generic lws_system blobs can cover client certs + key, let's
add support for applying one of the blob sets to a specific client
connection (rather than doing it via the vhost).
2019-12-09 14:48:54 +00:00
Andy Green
8e91a0d723 mbedtls: cast ecdh enum type for some toolchains 2019-11-27 07:39:37 +00:00
Andy Green
6ed3d8a9dd client: also allow stashed host param for client tls
Client connection items for protocols other than http ones
will never get into an ah.  Allow use of the values from the
client stash allocation instead if present.
2019-11-20 10:24:48 +00:00
Andy Green
0f7f27801e http redirect: 303: force method to GET
This teaches http client stuff how to handle 303 redirects... these
can happen after POST where the server side wants you to come back with
a GET to the Location: mentioned.

lws client will follow the redirect and force GET, this works for both
h1 and h2.  Client protocol handler has to act differently if it finds
it is connecting for the initial POST or the subsequent GET, it can
find out which by checking a new api lws_http_is_redirected_to_get(wsi)
which returns nonzero if in GET mode.

Minimal example for server form-post has a new --303 switch to enable
this behaviour there and the client post example has additions to
check lws_http_is_redirected_to_get().
2019-11-17 10:47:01 +00:00
Andy Green
640a3f177c http_proxy: fix for mbedtls 2019-11-16 09:00:15 +00:00
Zhiwen Zheng
34eca205e5 acme: add wildcard support to CSR 2019-11-06 16:02:36 +00:00
Andy Green
2bc0b97b45 acme: mbedtls: update genrsa apis 2019-11-06 16:02:33 +00:00
Andy Green
6b4b2f28be alpn: move out of tls-server so it can be used if server disabled 2019-11-06 06:39:28 +00:00
Kristján Valur Jónsson
4c224eb64b fix integer conversions from 64 bit 2019-10-27 16:29:04 +00:00
Andy Green
eda6707a84 client: tls cert in mem 2019-10-12 12:41:14 +01:00