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

2336 commits

Author SHA1 Message Date
Andy Green
e83860d1bc plat: add extra helpers hiding ESP32 quirks 2017-12-01 11:37:36 +08:00
Andy Green
91a821c793 esp32: align with esp-idf changes
LWIP_SOCKET_OFFSET is now nonzero, which I handled a while back.

But the C api support for it is broken in esp-idf.

select() takes unmodified fds, but FD_SET / FD_ISSET etc must have the
offset subtracted on their args.

With this we are working on current HEAD esp-idf.
2017-12-01 11:37:36 +08:00
Andy Green
f6de7465ec lws_compare_time_t: conceal time discontiguities on all platforms
This provides platform-independent support for time discontiguities.

On embedded without battery RTC, commonly we only get time after
NTP completes.  This makes the cert checking happen when we have
a reasonable time and introduces lws_compare_time_t() to correctly
compare time_t s that may sit on either side of a time discontiguity.
2017-12-01 11:37:36 +08:00
Andy Green
e1cdb1f328 close: make sure all paths capture original state 2017-12-01 11:37:36 +08:00
Tomas Chmelar
3031666dc7 parser: add x-auth-token 2017-12-01 11:37:36 +08:00
Andy Green
6c484b2b31 h2: provide parser buffer at a time 2017-12-01 11:37:35 +08:00
Andy Green
2a30cd8ba7 h2-ws-draft-02
This implements:

https://www.ietf.org/id/draft-mcmanus-httpbis-h2-websockets-02.txt

it's untested since no compatible clients/browsers available yet.
2017-12-01 11:37:35 +08:00
Andy Green
a4148a13ba refactor-eliminate-lws-union
The union used to make a lot of sense to save space between
mutually exclusive modes.  But the fact the http2 struct
contains the http1 struct as well as it appearing in the
union means the http1 struct belongs outside the union.

This patch

 - eliminates the union
 - puts the http_related struct directly in struct lws
 - removes http_related from h2
 - puts h2 directly in struct lws if enabled for build
 - changes ws to be a pointer, allocated if we upgrade to ws
   (the ws part contains a 135 byte char array for ping / close)


Again all of this is entirely private / internal and doesn't affect
any apis.
2017-12-01 11:37:35 +08:00
Andy Green
df46d8827c refactor-struct-lws-hdr
Migrate what used to be in lws_hdr_related into either the ah
or the wsi, and eliminate it along with the three different ways
used to access things inside it.

Eg wsi->u.hdr.ah and wsi->u.http.ah become wsi->ah

These changes are internal-only, in private-libwebsockets.h and lib.
2017-12-01 11:37:35 +08:00
Alexey Reznichenko
93846135f2 Add a flag to disable CMake exports
Add LWS_EXPORT_LWSTARGETS (defaults to ON) that can be used to disable
  CMake export targets as well as install export for libwebsockets.

AG: add _WITH_
2017-12-01 11:37:35 +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
516001db8a esp32-selfsigned 2017-12-01 11:37:35 +08:00
Ben Delarre
946bfa2f18 Uses PROJECT_NAME instead of DIRNAME for binary filename 2017-12-01 11:37:35 +08:00
Ben Delarre
3db1ce0953 Esp32: allow build on windows 2017-12-01 11:37:35 +08:00
Ben Delarre
3160605462 docs: whitespace and add existing READMEs to doxygen list 2017-12-01 11:37:35 +08:00
Ben Delarre
dcf5a83ee4 esp32: move check for xxd and genromfs from CMake to esp32.mk 2017-12-01 11:37:35 +08:00
Andy Green
37e8ee2c00 windows: CHECK_FUNCTION_EXISTS workaround 2017-12-01 11:37:35 +08:00
Andy Green
c5f6d180dd mbedtls: handle NET_SEND_FAILED
Under the condition the associated client went away (turn off WLAN at the
client), we can spin forever mistaking NET_SEND_FAILED for WANT_WRITE,
which was also true.  This makes sure we understand that was fatal
immediately.
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
ad07d95026 cleanups 2017-12-01 11:37:35 +08:00
Andy Green
79d2038fdf esp32 fixes
This add support for a platform socketfd offset.
2017-12-01 11:37:35 +08:00
Andy Green
3ec7c1ab21 ACME client plugin
This adds support for a plugin that can be attached to a vhost
to acquire and maintain its TLS cert automatically.

It works the same with both OpenSSL and mbedTLS backends, but
they can't share auth keys, delete the 'auth.jwk' file as it is
in the example JSON when switching between libs
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
713aab17f8 additional vhost member accessors 2017-12-01 11:37:35 +08:00
Ralph Lessmann
33b40e0ae4 mingw: fixes 2017-12-01 11:37:33 +08:00
Andy Green
0724f8982a h2: fix multiple cookie header handling
Firefox 57 at least still sends multiple cookie: headers over h2.
Correctly aggregate them with a ';' delimiter.
2017-12-01 11:12:37 +08:00
Andy Green
53bbc6be33 cmake: dont build ssh stuff if no SSL enabled 2017-11-28 07:57:36 +08:00
Pavel Shramov
66916394ed lib: Spelling fixes based on debian packaging 2017-11-28 07:46:22 +08:00
Andy Green
2b30c82b9e lejp: dont underflow with anonymous braces 2017-11-26 19:17:11 +08:00
Andy Green
a76e9aad11 lejp: handle empty arrays 2017-11-26 19:17:11 +08:00
Andy Green
09f59ba3b8 lwjp-conf: quieten init logging 2017-11-26 19:17:11 +08:00
Andy Green
1f37ec0be9 add selfsigned cert generation api 2017-11-26 19:17:11 +08:00
Andy Green
a798db0e2b vhost: check cert validity dates
After startup, and once per day, check the validity dates on our ssl certs,
and broadcast callbacks with the information so interested plugins can
know.

If our clock is < May 2016, we don't try to judge the certs, because clearly
we don't know what time it is.
2017-11-26 19:17:10 +08:00
Andy Green
fb4397f841 cleanups 2017-11-26 19:17:10 +08:00
Adam Wolk
2befafca77 cmake: only generate test cert when SERVER and TESTAPPS enabled
apart from LWS_WITHOUT_TEST_SERVER the test server will also not be
built if LWS_WITHOUT_TESTAPPS or LWS_WITHOUT_SERVER is defined,
we update the CMake configuration to skip cert generation and
installation in those cases.

Signed-off-by: Adam Wolk <adam.wolk@koparo.com>
2017-11-26 19:17:06 +08:00
Andy Green
0ed131e6a7 post-demo: some platforms cant handle NULL vsnprintf strings 2017-11-26 19:16:58 +08:00
Petar Paradzik
0060af62c5 mbedtls: add support for optional peer certificate
Check for LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED...

AG: Fix missing stanza needed to confirm client cert needed at all

Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>
2017-11-26 19:16:17 +08:00
Petar Paradzik
121d5d5940 mbedtls: client cert workaround
https://github.com/warmcat/libwebsockets/pull/1075#issuecomment-340730880
2017-11-26 19:16:17 +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
41d1326da0 appveyor artifacts debug 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
ae8915861a client: handle bio_create failing
Plus some line length cleaning
2017-11-26 19:16:17 +08:00
Andy Green
1d5bd23268 bsd: support foreign thread event changes while in poll wait
https://github.com/warmcat/libwebsockets/issues/314
2017-11-26 19:16:17 +08:00
Andy Green
74fddbc09e cancel_service: change to event-loop agnostic implementation
- Add platform helpers for pipe creation.

 - Change the direct-to-fds implementation to create a wsi for each
   pt and use the normal apis to bind it to the event loop.

 - Modifiy context creation and destroy to create and remove the
   event pipe wsis.

 - Create the event pipe wsis during context create if using the
   default poll() event loop, or when the other event loops start
   otherwise.

 - Add handler that calls back user code with
   LWS_CALLBACK_EVENT_WAIT_CANCELLED

This patch allows you to call `lws_cancel_service(struct lws_context *context)`
from another thread.

It's very cheap for the other thread to call and is safe without
locking.

Every use protocol receives a LWS_CALLBACK_EVENT_WAIT_CANCELLED from
the main thread serialized normally in the event loop.
2017-11-26 19:16:17 +08:00
Andy Green
97cd393649 cmake: refactor options into groups and move to top of file 2017-11-26 19:16:17 +08:00