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

223 commits

Author SHA1 Message Date
Orgad Shaneh
10660466c1 openssl-server: Fix null dereference
Reported by GCC9.
2019-05-31 06:16:52 +08:00
Orgad Shaneh
71131adb9c tls: Fix yet another strict-aliasing issue on GCC 4.1 2019-05-30 06:03:47 +08:00
Andy Green
832fdae7fd mbedtls: correct memory cert usage
https://github.com/warmcat/libwebsockets/issues/1569
2019-05-11 08:07:27 +01:00
kzhdev
c40394f968 openssl: client: handle no tcr 2019-04-06 05:52:23 +08:00
Andy Green
ede747f1bc openssl: client: check wsi from openssl private data
v2.4 was patched to check NULL wsi in the verify callback,
nobody has reported it on later versions, but might as well
check it too.
2019-04-03 08:06:14 +08:00
Andy Green
62c5a784e3 alpn: handle ALLOW_NON_SSL_ON_SSL_PORT 2019-03-22 05:30:22 +08:00
Andy Green
462847bb6f lws_dll: remove lws_dll_lws and deprecate lws_dll_remove 2019-03-21 06:19:31 +08:00
Andy Green
30eb3e94ab openssl: gencrypto: aes gcm AAD: use EncryptUpdate or DecryptUpdate to set AAD
Until 1.1.1b OpenSSL didn't mind we were setting AAD for AES GCM
using EVP_EncryptUpdate() for both encrypt and decrypt... but now
it noticed and the bug is fixed.
2019-03-21 06:18:32 +08:00
Andy Green
45f2c9f9f8 openssl3: handle EC_POINT_get_affine_coordinates api change 2019-03-20 21:00:29 +08:00
Andy Green
555c34b044 openssl: reuse client SSL_CTX where possible
If you have multiple vhosts with client contexts enabled, under
OpenSSL each one brings in the system cert bundle.

On libwebsockets.org, there are many vhosts and the waste adds up
to about 9MB of heap.

This patch makes a sha256 from the client context configuration, and
if a suitable client context already exists on another vhost, bumps
a refcount and reuses the client context.

In the case client contexts are configured differently, a new one
is created (and is available for reuse as well).
2019-03-18 06:54:38 +08:00
Andy Green
59a2a787ee openssl: try to reduce memory usage 2019-03-16 10:17:28 +08:00
Andy Green
75c058e250 mbedtls: handle vhost without valid cert gracefully 2019-03-16 09:54:52 +08:00
Santeri Hernejärvi
5d1cd3cb4b mbedtls: Fix reads getting stuck when the socket has disconnected
We've seen this behaviour when iOS resumes from sleep:

dbg> 0x11cd03750: ssl err dbg> lws_ssl_capable_read: WANT_READ
dbg> 0x11cd03750: LWS_SSL_CAPABLE_MORE_SERVICE
dbg> SSL Capable more service
dbg> 0x11cd03750: SSL_read says -1
dbg> 0x11cd03750: ssl err 2 errno 57
dbg> lws_ssl_capable_read: WANT_READ
dbg> 0x11cd0375dbg> SSL Capable more service
dbg> 0x11cd03750: SSL_read says -1
dbg> 0x11cd03750: ssl err 2 errno 57
dbg> lws_ssl_capable_read: WANT_READ
2019-03-14 19:09:33 +08:00
Andy Green
3b65f9885b old openssl: dont build with membuffer apis 2019-03-12 11:57:43 +08:00
Andy Green
c3f30bf1fa vhost info: add memory buffer cert support 2019-03-12 11:57:43 +08:00
Andy Green
0079099f10 vhost: add pprotocols to vhost info
info.protocols works okay, but it has an annoying problem... you have to know
the type for each protocol's pss at the top level of the code, so you can set
the struct lws_protocols user_data size for it.

Lws already rewrites the protocol tables for a vhost in the case of runtime
protocol plugins... this adapts that already-existing code slightly to give
a new optional way to declare the protocol array.

Everything works as before by default, but now info.protocols may be NULL and
info.pprotocols defined instead (if that's also NULL, as it will be if you
just ignore it after memsetting to 0, then it continues to fall back to the
dummy protocol handler as before).

info.pprotocols is a NULL-termined array of pointers to lws_protocol
structs.  This can be composed at the top level of your code without knowing
anything except the name of the externally-defined lws_protocol struct(s).

The minimal example http-server-dynamic is changed to use the new scheme as
an example.
2019-03-10 08:02:02 +08:00
Andy Green
f8cd973f85 mingw: windows: make minimal examples build 2019-03-10 08:02:02 +08:00
Andy Green
30d992dbe2 clean: LWS_SSL_ENABLED use vh as the macro arg name to clarify what should be given 2019-03-10 08:02:02 +08:00
Andy Green
2d086db6e8 codacy: fixes for warnings 2019-03-10 08:02:02 +08:00
Andy Green
e4a65c948e windows: treat syscall and errno 0 as WANT_READ
https://libwebsockets.org/pipermail/libwebsockets/2019-February/007800.html
2019-02-07 06:24:14 +08:00
Andy Green
e7aacc8510 jwk: openssl: fix key parameter ordering for older OpenSSL 2019-01-30 07:19:38 +08:00
Andy Green
658afbc658 crypto: openssl: use EVP hmac objects directly 2 2019-01-29 15:28:56 +08:00
Andy Green
aada7348ea openssl: jwk: rsa: also import p and q 2019-01-27 19:21:47 +08:00
Andy Green
043700a4b0 optee: remove build system 2019-01-15 06:59:48 +08:00
Andy Green
84a57540ab LWS_WITH_NETWORK: cmake option for no network code 2019-01-13 07:54:57 +08:00
Andy Green
613993300d x509-warning-fixes 2019-01-11 18:46:38 +08:00
Andy Green
d2a1bbd8aa optee: other plat fixes 2019-01-11 17:14:14 +08:00
Andy Green
ad9c99a6d3 mbedtls: finer-grained enable checks and OP-TEE 2019-01-11 13:17:06 +08:00
Andy Green
4608dfc581 tls: client: also allow vhost client ctx to be initialized with in-memory certs 2019-01-11 13:17:00 +08:00
Andy Green
d995d75ffb adopt: keep most of adopt.c even with WITHOUT_SERVER 2019-01-11 13:16:59 +08:00
Andy Green
0adc845507 lws-x509: validation functions 2018-12-31 20:35:54 +08:00
Andy Green
21889b53f7 ecdh-es
Mainly JWE support for ecdh-es and initial refactor to support multiple
recipients / signatures.
2018-12-27 06:45:32 +08:00
Andy Green
eda102e397 jwe 2018-12-27 06:45:32 +08:00
Andy Green
a3dcc95471 genec: generic ECDH crypto layer
!!! WIP

This implements the "genec" layer wrapping mbedtls + openssl
ECDH support.

API tests are added for the parts that are implemented so far.

Stuff related to ec at all, like keys, are prefixed lws_genec_.
Stuff specific to ECDH are prefixed lws_genecdh_.
2018-12-27 06:45:31 +08:00
Andy Green
47e14ba34b genrsa: add OAEP and PSS and convert openssl to EVP
Wanting PSS padding on signatures triggers and avalanche of
openssl EVP conversions as the only way to do it with the
openssl public apis.
2018-12-27 06:45:31 +08:00
Andy Green
ddb94d4e27 genaes: generic AES layer independent of tls library
Although RSA can be used directly for signing / JWS
on large chunks of data since it's only operating on
the hash, when JWE support arrives, which allows bulk
encryption, it's going to be mandatory to support
secondary AES ciphers to use on the bulk data.

This adds generic support for all AES modes that OpenSSL
and mbedTLS have in common, works on both mbedTLS and
OpenSSL the same, and adds unit tests for each mode
in api-test-gencrypto, to run in CI.
2018-12-27 06:45:31 +08:00
Andy Green
440dacc992 JOSE: refactor and prepare for JWE
Until now the JOSE pieces only had enough support for ACME.
This patch improves the JWK parsing to prepare for more
complete support and for adding JWE, genaes and genec in
later patches.
2018-12-27 06:45:31 +08:00
=?UTF-8?q?Samuel=20Lor=C3=A9tan?=
31d1d73f74 openssl: Allow IP-based SAN in automatic hostname check
With OpenSSL, `X509_VERIFY_PARAM_set1_host` only checks matching hostnames and alternative names that are domain-based.

This change tries calling `X509_VERIFY_PARAM_set1_ip_asc` first, which attempts to parse the hostname as an IP address (v4 or v6). If this fails, it'll fall back to the current `X509_VERIFY_PARAM_set1_host` behavior.
2018-12-07 06:00:24 +08:00
Andy Green
08b5ad9299 role: raw-proxy 2018-12-01 11:05:59 +08:00
Andy Green
b318877cd9 adopt: allow associated accepted vhost connections to specific role
Normalize the vhost options around optionally handling noncompliant
traffic at the listening socket for both non-tls and tls cases.

By default everything is as before.

However it's now possible to tell the vhost to allow noncompliant
connects to fall back to a specific role and protocol, both set
by name in the vhost creation info struct.

The original vhost flags allowing http redirect to https and
direct http serving from https server (which is a security
downgrade if enabled) are cleaned up and tested.

A minimal example minimal-raw-fallback-http-server is added with
switches to confirm operation of all the valid possibilities (see
the readme on that).
2018-12-01 11:05:59 +08:00
Rosen Penev
4edd5cad50 OpenSSL: fix ECC support build-time check
With at least OpenSSL 1.1.0, checking the header is not enough. OpenSSL
does provide a way to check it directly though.

Fixes compilation without ECC support.
2018-11-28 15:06:05 +08:00
Andy Green
edeb8a59fa boringssl: update 2018-11-23 10:52:39 +08:00
Andy Green
9bed6d6fc6 clean: general whitespace cleanup 2018-11-23 08:47:56 +08:00
Rosen Penev
c5d6255487 tls: Fix compile without deprecated OpenSSL APIs
These headers are included implicitly with others when deprecated APIs are enabled.
2018-11-09 08:33:04 +08:00
Andy Green
175f2a2d18 tls pending: convert to lws_dll_lws
Also add a check for pending after accept, in case pending was aggregated.
2018-11-05 14:43:50 +08:00
Andy Green
93d4e186c2 openssl tls1.3: allow setting ciphersuites at context creation time
https://github.com/warmcat/libwebsockets/issues/1440
2018-10-27 08:05:21 +08:00
Andy Green
20fb55934b client vhost OpenSSL set and clear options
https://github.com/warmcat/libwebsockets/issues/1438
2018-10-26 13:55:36 +08:00
Andy Green
38fe22e4db openssl: info log with cipher details and tls version 2018-10-20 07:54:58 +08:00
Andy Green
da444d04d1 lws_time_in_microseconds: export
Rename time_in_microseconds() and export the internal
api as lws_time_in_microseconds()
2018-10-14 06:15:36 +08:00
Andy Green
d03c57b87f quench logging 2018-10-13 08:16:27 +08:00