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

192 commits

Author SHA1 Message Date
Dmytro Ivanov
ff2b1eab36 tls:Implement client_ssl_ca_mem/client_ssl_ca_mem_len to load root CA certs from memory. 2018-07-17 18:25:53 +08:00
Rosen Penev
eb4cefceae openssl: Fix compile with 1.1.0 - deprecated APIs
These function have been deprecated. Keep compatibility with OpenSSL 1.0.2 as it is still supported.
2018-06-30 09:42:44 +08:00
Andy Green
de064fd65a refactor: core code in lib/core and private-libwebsockets.h to core/private.h
This commit is coverity-clean as tested

cmake .. -DLWS_WITH_MINIMAL_EXAMPLES=1 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ACME=1 -DLWS_WITH_LWSWS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_HTTP2=1 -DLWS_WITHOUT_CLIENT=0 -DLWS_WITHOUT_SERVER=0 -DLWS_UNIX_SOCK=1 -DLWS_WITH_TLS=0 -DLWS_WITH_MBEDTLS=0 -DLWS_WITH_CGI=1 -DCMAKE_BUILD_TYPE=DEBUG -DLWS_WITH_GENERIC_SESSIONS=1 -DLWS_WITH_RANGES=1 -DLWS_ROLE_WS=1 -DLWS_MAX_SMP=16 -DLWS_ROLE_H1=1 -DLWS_WITH_WOLFSSL=0 -DLWS_WITH_LIBEV=0 -DLWS_WITH_LIBEVENT=1
2018-05-03 10:49:36 +08:00
Andy Green
a01ad0dd20 hrtimer: add support for libevent and libev 2018-05-02 19:27:33 +08:00
Andy Green
bce8cca042 refactor: also migrate tls to the ops struct and private.h pattern
Several new ops are planned for tls... so better to bite the bullet and
clean it out to the same level as roles + event-libs first.

Also adds a new travis target "mbedtls" and all the tests except
autobahn against mbedtls build.
2018-05-02 12:10:36 +08:00
kaleb-himes
65b68bdc70 wolfSSL updates 2018-04-28 07:55:27 +08:00
Andy Green
ac6c48d98f refactor: most preparation for -DLWS_ROLE_H1=0 2018-04-27 19:16:50 +08:00
Andy Green
7ff8f023d1 context info struct: make lws usage all const 2018-04-27 08:37:20 +08:00
Andy Green
27e86e2641 cmake: allow setting LWS_ROLE_WS
You can build lws without support for ws, with -DLWS_ROLE_WS=0.

This is thanks to the role ops isolating all the ws-specific business
in the ws role.

Also retire more test apps replaced by minmal-examples.
2018-04-25 08:42:18 +08:00
Andy Green
8829c2f365 selftests
This converts several of the selftests to return a status in their exit code
about whether they 'worked'.

A small bash script framework is added, with a selftest.sh in the mininmal
example dirs that support it, and a ./minimal-examples/selftests.sh script
that can be run from the build dir with no args that discovers and runs all
the selftest.sh scripts underneath.

That is also integrated into travis and the enabled tests must pass now for
travis to pass.  Travis does not have a modern libuv so it can't run a
couple of tests which are nulled out if it sees it's running in travis env.
2018-04-19 16:16:48 +08:00
Andy Green
aa816e98a9 alpn: assemble defaults from roles and allow override
Since new roles may be incompatible with http, add support for
alpn names at the role struct, automatic generation of the
default list of alpn names that servers advertise, and the
ability to override the used alpn names per-vhost and per-
client connection.

This not only lets you modulate visibility or use of h2,
but also enables vhosts that only offer non-http roles,
as well as restricting http role vhosts to only alpn
identifiers related to http roles.
2018-04-19 16:15:10 +08:00
Andy Green
16e2f09710 refactor mode and states into roles and states 2018-04-06 12:22:19 +08:00
Andy Green
9a51bd0a63 LWS_TLS_CERT_INFO_OPAQUE_PUBLIC_KEY 2018-04-06 10:38:04 +08:00
Andy Green
9586acb560 Coverity 189189: client: new openssl alpn handling off-by-one 2018-04-06 10:38:04 +08:00
Andy Green
fddebfcfae QA 2018-04-06 10:38:04 +08:00
Andy Green
2a9b6f54c6 client: h2
This adds h2 http support for the client api.

The public client api requires no changes, it will detect by
ALPN if the server can handle http/2, if so, it will use it.

Multiple client connections using the lws api will be mapped on
to the same single http/2 + tls socket using http/2 streams
that are serviced simultaneously where possible.
2018-04-06 10:38:03 +08:00
Andy Green
865b2439ce mingw: also workaround ENOTCONN 2018-04-06 10:38:03 +08:00
Andy Green
b45956fcb9 client: add alpn processing on mbedtls and openssl
This just supports "http/1.1" alpn and lets the client know it
can use keepalive earlier if it affirmitively negotiated
"http/1.1" on alpn.

mbedTLS wrapper needed a small adaptation to also allow
per-client-ssl control of the alpn negotiation list.
2018-04-06 10:38:03 +08:00
Fabio Alessandrelli
94f3981bef mbedtls: wrapper: client: Force mbedTLS to attemp to verify cert
AG: unlike openssl, mbedtls does not load the system trust store.
So this change will make client tls operations that work OK on openssl fail on
mbedtls unless you provide the correct CA cert.

This allows lws to distinguish between untrusted CAs, hostname
mismatches, expired certificates.

NOTE: LCCSCF_ALLOW_SELFSIGNED actually allows for untrusted CAs, and
will also skip hostname verification. This is somewhat a limitiation of
the current lws verification process.

AG: improve error reporting up to the CLIENT_CONNECTION_ERROR argument
and add a note specific to mbedtls in the test client.  Adapt the test
client to note the CA requirement if built with mbedTLS.  Adapt the
minimal test clients to have the CAs available and use them if mbedTLS.
2018-04-06 10:38:03 +08:00
Andy Green
b04708178a minimal: http-server-tls 2018-04-06 10:38:03 +08:00
Andy Green
302f8fad82 h2 ws: fixes against chrome 2018-04-06 10:38:02 +08:00
Andy Green
aae2c24678 lws_snprintf 2018-03-12 09:28:42 +08:00
Andy Green
dc15a77dfa openssl: avoid warning on versions with ECDH header 2018-03-11 18:07:16 +08:00
Andy Green
7bc6383759 LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT: fixes after tls refactor
https://github.com/warmcat/libwebsockets/issues/1191
2018-02-27 07:48:25 +08:00
Andy Green
3eae5b1363 openssl: treat SYSCALL at connect as always fatal 2018-01-08 06:35:12 +08:00
Sergio Hernández
f3c6fac3cb Detect dead socket on iOS when server closed connection 2017-12-27 10:02:34 +08:00
Andy Green
e8e448df3e plat optee: updates 2017-12-20 10:44:21 +08:00
Andy Green
d58d749b30 acme: adaptations through plat for esp32 2017-12-11 13:30:12 +08:00
Andy Green
5b74d7108b gcov: add in cmake and adapt defaults
1) Introduce LWS_WITH_GCOV to build with gcc / clang coverage instrumentation.

$ cd build
$ make clean && rm -f `find . -name "*.gcno" -o -name "*.gcda"` && make -j16 && sudo make install && sudo /usr/local/bin/libwebsockets-test-server -s
...
$ gcov `find . -name *.c.gcno | grep -v test-apps` -b | sed "/\.h.\$/,/^$/d"

The above are available in two helper scripts

 - scripts/build-gcov.sh
 - scripts/gcov.sh

2)

CMake defaults changed:

 - LWS_WITH_ZIP_FOPS: OFF
 - LWS_WITH_RANGES: OFF
 - LWS_WITHOUT_EXTENSIONS: ON
 - LWS_WITH_ZLIB: OFF

New CMake controls that default-OFF:

 - LWS_WITH_GENHASH
 - LWS_WITH_GENRSA

these are implied by LWS_WITH_JWS (which is implied by LWS_WITH_ACME)

3) rename ./lib/tls/XXX/server.c and client.c to XXX-server.c / XXX-client.c.

This is because gcov dumps its results using the .c filename part only,
the copies overwrite each other if there are different .c files in the tree
with the same filename part.

4) Add onetime test-client mode and test to ./test-apps/attack.sh

5) Add gcov howto in READMEs/README.build.md using attack.sh
2017-12-01 11:37:35 +08:00
Andy Green
b06665b851 mbedtls: improve SNI for client certs 2017-12-01 11:37:35 +08:00
Andy Green
813b019bd1 lws_tls_server_certs_load: separate to allow cert attach later 2017-12-01 11:37:35 +08:00
Andy Green
a5514d2b2b LWS_SERVER_OPTION_IGNORE_MISSING_CERT 2017-12-01 11:37:35 +08:00
Andy Green
0c254aba87 tls: add csr generation 2017-12-01 11:37:35 +08:00
Andy Green
1f37ec0be9 add selfsigned cert generation api 2017-11-26 19:17:11 +08:00
Petar Paradzik
a552de400a ssl: add support for checking cert existance and verification
Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
2017-11-26 19:16:17 +08:00
Petar Paradzik
2f7bd10487 Subject: ssl: fix source and destination overlap in strcpy
Use memmove instead...

AG add explanation for union name[] member length.

Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
2017-11-26 19:16:17 +08:00
Petar Paradzik
939436b793 Subject: ssl: fix x509 memory leaks
Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
2017-11-26 19:16:17 +08:00
Andy Green
00ffebfd24 tls: add x509 query api
This adds a single api on lws that allows querying elements from the
peer certificate on a connection.

The api works the same regardless of the TLS backend.
2017-11-26 19:16:17 +08:00
Andy Green
be525cb624 appveyor: Enable 64-bit build with OpenSSL and HTTP2
Fix warnings found from that

Introduce lws_ptr_diff(head, tail) helper to normalize
pointers to char *, do the subtraction and cast the
result to int.
2017-11-26 19:16:17 +08:00
Andy Green
c32a22c20b lws-genrsa: add resuable backend-independent rsa decrypt in tls/ and migrate sshd to it 2017-11-10 16:56:44 +08:00
Andy Green
dd3e5619cb lws_genhash: add HMAC
Like the simple hashes, these work the same regardless of if the backend is
OpenSSL or mbedTLS.

Also move into ./lib/tls/ and split into two specific to mbedtls or openssl
backends.
2017-11-10 16:56:44 +08:00
Andy Green
89cb55ea58 tls: split out common, openssl and mbedtls code
- introduce lib/tls/mbedtls lib/tls/openssl
 - move wrapper into lib/tls/mbedtls/wrapper
 - introduce private helpers to hide backend

This patch doesn't replace or remove the wrapper, it moves it
to lib/tls/mbedtls/wrapper.

But it should be now that the ONLY functions directly consuming
wrapper apis are isolated in

  - lib/tls/mbedtls/client.c (180 lines)
  - lib/tls/mbedtls/server.c (317 lines)
  - lib/tls/mbedtls/ssl.c    (325 lines)

In particular there are no uses of openssl or mbedtls-related
constants outside of ./lib/tls any more.
2017-10-25 07:17:29 +08:00