summaryrefslogtreecommitdiff
path: root/src/mod_mbedtls.c
Commit message (Collapse)AuthorAgeFilesLines
* [mod_mbedtls] check MBEDTLS_DEBUG_C for debug funcGlenn Strauss2023-05-031-0/+2
| | | | wrap mbedtls_debug_set_threshold() in #ifdef for MBEDTLS_DEBUG_C
* [TLS] $SERVER["socket"] inherit global ssl.engineGlenn Strauss2023-05-031-0/+1
| | | | | | | | | | | | | | | | | | $SERVER["socket"] inherits ssl.engine = "enable" from global scope fixes issue of TLS-enabled socket, but missing config, if ssl.engine = "enable" in global scope and $SERVER["socket"] does not contain ssl.engine = "enable" e.g. default TLS-enabled, and explicitly disabled on specific sockets server.port = 443 ssl.engine = "enable" ssl.pemfile = ... ssl.privkey = ... $SERVER["socket"] == ":80" { ssl.engine = "disable" } $SERVER["socket"] == "[::]:80" { ssl.engine = "disable" } $SERVER["socket"] == " :443" { } $SERVER["socket"] == "[::]:443" { }
* [build] _WIN32 __declspec(dllexport) *_plugin_initGlenn Strauss2023-05-031-0/+1
| | | | _WIN32 __declspec(dllexport) on mod_*_plugin_init()
* [TLS] fix spurious warning trace (fixes #3182)Glenn Strauss2023-01-051-2/+2
| | | | | | | | (thx flynn) x-ref: "Test config reports invalid ssl.pemfile in $HTTP["host"] condition" https://redmine.lighttpd.net/issues/3182
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-27/+13
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [multiple] mark mod_*_plugin_init() funcs coldGlenn Strauss2022-12-071-0/+1
|
* [TLS] simplify TLS config; remove deprecated optsGlenn Strauss2022-11-301-177/+22
| | | | | | | | | | | | | | | | | simplify TLS config; remove deprecated options These scheduled lighttpd behavior changes have been announced over the past year. lighttpd aims to provide reasonably secure TLS configuration defaults, and to periodically review and update TLS configuration defaults. Doing so reduces the need for distros, packagers, and end-users to specify their own TLS config customizations, which may then be neglected or cargo-culted far into the future, instead of being periodically updated to use stronger defaults. x-ref: https://wiki.lighttpd.net/Docs_SSL
* [TLS] upgrade default cipher list to stronger setGlenn Strauss2022-11-301-5/+77
| | | | | | | | | | | | | | | | | | | | | upgrade default cipher list to stronger set, changing default from "HIGH" to "EECDH+AESGCM:AES256+EECDH:CHACHA20:!SHA1:!SHA256:!SHA384" openssl ciphers 'EECDH+AESGCM:AES256+EECDH:CHACHA20:!SHA1:!SHA256:!SHA384' expands to "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-CCM8:ECDHE-ECDSA-AES256-CCM:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:PSK-CHACHA20-POLY1305" Most of these ciphers are widely supported and have been for many years. These scheduled lighttpd behavior changes have been announced over the past year. Providing a strong default cipher list reduces the need for distros, packagers, and end-users to specify their own cipher lists, which may then be neglected or cargo-culted far into the future, instead of being periodically updated to use stronger defaults. x-ref: https://wiki.lighttpd.net/Docs_SSL
* [TLS] handle '+' on ssl-conf-cmd "Options"Glenn Strauss2022-11-301-0/+2
|
* [mod_mbedtls] config renegotiation;not recommendedGlenn Strauss2022-10-161-5/+4
| | | | configuring renegotiation (not recommended)
* [TLS] ssl.openssl.ssl-conf-cmd "DHParameters"Glenn Strauss2022-10-011-14/+31
| | | | | | | | | support "DHParameters" in ssl.openssl.ssl-conf-cmd (replacement for ssl.dh-file) isolate code setting DHParameters into its own subroutine (code reuse) Note: TLS library defaults should be preferred over specifying DH params
* [multiple] quiet coverity warnings using castsGlenn Strauss2022-09-151-1/+1
|
* [mod_mbedtls] fix crt chain construction logicGlenn Strauss2022-06-041-3/+4
| | | | | | fix crt chain construction logic inversion (thx DamienT)
* [TLS] inherit ssl.engine from global scopeGlenn Strauss2022-06-041-6/+0
| | | | | | | | | | | | | | | | | | | | | | Since lighttpd 1.4.56, an oversight in config processing missed setting explicitly p->conf.ssl_enabled = 0 in network.c when initializing conditions. When ssl.engine = "enable" in lighttpd.conf global scope, the missing reset in network.c required non-TLS ports (e.g. $SERVER["socket"] == ":80") to contain ssl.engine = "disable" in order for requests to those ports to be served rather than erroring. (This error was discovered during collaboration with jens-maus in https://github.com/jens-maus/RaspberryMatic/pull/1847) There have been zero other instances of this error reported since the release of lighttpd 1.4.56 in Nov 2020. Therefore, having ssl.engine = "enable" inherited from the global scope is unlikely to have any widespread impact in practice, and enabling ssl.engine = "enable" (along with TLS certificate configuration) is now recommended as default. When ssl.engine = "enable" in the global scope, ssl.engine = "disable" should be specified in those $SERVER["socket"] conditions where clear-text is desired.
* [multiple] simplify bytes_in/bytes_out accountingGlenn Strauss2022-05-111-6/+1
| | | | | | | | | | | | | | | | encapsulate accounting calculations in http_request_stats_bytes_in() http_request_stats_bytes_out() more accurate accounting for HTTP/1.1 bytes_in on keep-alive requests (affects case where client pipelines HTTP/1.1 requests) remove con->bytes_read and con->bytes_written (no longer needed since request_st was split from connection struct and request bytes_read_ckpt and bytes_written_ckpt are maintained for HTTP/1.x bytes_in and bytes_out accounting. Also, further back, chunkqueue internal accounting was simplified to maintain bytes_in and bytes_out to always match chunkqueue length)
* [multiple] reset http vers, avoid rare crash (fixes #3152)Glenn Strauss2022-05-051-2/+4
| | | | | | | | | | | | | | | (thx ultimator) do not set r->http_version to HTTP_VERSION_2 when selecting TLS ALPN if r->handler_module already set, since handler module is likely mod_sockproxy, and con->h2 will not get initialized. This does continue to select "h2", so the mod_sockproxy backend should be prepared to receive the HTTP/2 client connection preface. x-ref: "Random Segfaults with version 1.4.64 w/ mod_sockproxy and ALPN h2" https://redmine.lighttpd.net/issues/3152
* [multiple] limit scope of socket config optionsGlenn Strauss2022-05-051-9/+9
| | | | | warn if socket config options used only at startup are used outside global scope or $SERVER["socket"] with '==' condition
* [mod_mbedtls] use newer mbedtls 3.2.0+ interfacesGlenn Strauss2022-04-111-0/+35
|
* [TLS] warn if leaf cert read is inactive/expiredGlenn Strauss2022-03-281-1/+29
| | | | | | | When reading certificates, warn if leaf certificate is inactive/expired (according to notBefore, notAfter fields of leaf certificate) (note: not adding a delta for fudge factor when comparing times) (note: not currently verifying each certificate in chain)
* [mod_mbedtls] use newer mbedtls 3.2.0+ interfacesGlenn Strauss2022-03-251-4/+70
|
* [TLS] consistent debug.log-ssl-noise config typeGlenn Strauss2022-03-101-1/+1
| | | | | | | (thx flynn) x-ref: https://redmine.lighttpd.net/issues/3146#note-26
* [mod_mbedtls] use newer mbedtls 3.2.0+ interfacesGlenn Strauss2022-02-191-5/+22
|
* [mod_mbedtls] set usekeysize for mbedtls 3.2.0+Glenn Strauss2022-02-051-0/+1
|
* [mod_mbedtls] mbedtls_ssl_conf_groups for 3.1.0Glenn Strauss2022-01-191-4/+62
| | | | | use mbedtls_ssl_conf_groups() for mbedtls 3.1.0 (replaces deprecated mbedtls_ssl_conf_curves())
* [mod_mbedtls] remove use of out_left in mbedtls 3Glenn Strauss2022-01-191-1/+6
| | | | | | | | | | | | | remove use of ssl->out_left in mbedtls 3.0.0 Discussed in https://github.com/ARMmbed/mbedtls/issues/5331, the current implementations of mbedtls_net_send() and mbedtls_net_recv() return MBEDTLS_ERR_SSL_WANT_WRITE only when there is a partial write (though there is theoretical issue if writes are mixed with TLS alerts) x-ref: "issues migrating lighttpd mod_mbedtls to mbedtls 3.0.0" https://github.com/ARMmbed/mbedtls/issues/5331
* [mod_mbedtls] changes to build with mbedtls 3.0.0Glenn Strauss2022-01-191-60/+202
| | | | | | x-ref: "issues migrating lighttpd mod_mbedtls to mbedtls 3.0.0" https://github.com/ARMmbed/mbedtls/issues/5331
* [mod_mbedtls] reconstruct SSL_CLIENT_S_DNGlenn Strauss2022-01-181-17/+26
| | | | | | | | | | reconstruct SSL_CLIENT_S_DN in lighttpd due to limitations of mbedtls_x509_dn_gets(). Adds support for non-ASCII UTF-8, but loses support for multi-valued RDNs. x-ref: "Add access to mbedtls_x509_name::next_merged" https://github.com/ARMmbed/mbedtls/issues/5431
* [multiple] permit UTF-8 in SSL_CLIENT_S_DN_*Glenn Strauss2022-01-161-1/+1
| | | | | | | permit non-ASCII UTF-8 in SSL_CLIENT_S_DN_* x-ref: https://github.com/ARMmbed/mbedtls/pull/3326#issuecomment-1013921672
* [mbedtls] save (mbedtls_ssl_config *) in hctxGlenn Strauss2022-01-141-16/+13
| | | | (cleaner approach and compatible with mbedtls 3.0.0)
* [mod_mbedtls] lift size check out of DN loopGlenn Strauss2022-01-141-19/+11
| | | | | lift size check out of client Subject DN loop move loop invariant into for() declaration
* [multiple] Y2038 32-bit signed time_t mitigationsGlenn Strauss2021-09-041-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most OS platforms have already provided solutions to Y2038 32-bit signed time_t 5 - 10 years ago (or more!) Notable exceptions are Linux i686 and FreeBSD i386. Since 32-bit systems tend to be embedded systems, and since many distros take years to pick up new software, this commit aims to provide Y2038 mitigations for lighttpd running on 32-bit systems with Y2038-unsafe 32-bit signed time_t * Y2038: lighttpd 1.4.60 and later report Y2038 safety $ lighttpd -V + Y2038 support # Y2038-SAFE $ lighttpd -V - Y2038 support (unsafe 32-bit signed time_t) # Y2038-UNSAFE * Y2038: general platform info * Y2038-SAFE: lighttpd 64-bit builds on platforms using 64-bit time_t - all major 64-bit platforms (known to this author) use 64-bit time_t * Y2038-SAFE: lighttpd 32-bit builds on platforms using 64-bit time_t - Linux x32 ABI (different from i686) - FreeBSD all 32-bit and 64-bit architectures *except* 32-bit i386 - NetBSD 6.0 (released Oct 2012) all 32-bit and 64-bit architectures - OpenBSD 5.5 (released May 2014) all 32-bit and 64-bit architectures - Microsoft Windows XP and Visual Studio 2005 (? unsure ?) Another reference suggests Visual Studio 2015 defaults to 64-bit time_t - MacOS 10.15 Catalina (released 2019) drops support for 32-bit apps * Y2038-SAFE: lighttpd 32-bit builds on platforms using 32-bit unsigned time_t - e.g. OpenVMS (unknown if lighttpd builds on this platform) * Y2038-UNSAFE: lighttpd 32-bit builds on platforms using 32-bit signed time_t - Linux 32-bit (including i686) - glibc 32-bit library support not yet available for 64-bit time_t - https://sourceware.org/glibc/wiki/Y2038ProofnessDesign - Linux kernel 5.6 on 32-bit platforms does support 64-bit time_t https://itsubuntu.com/linux-kernel-5-6-to-fix-the-year-2038-issue-unix-y2k/ - https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html "Note: at this point, 64-bit time support in dual-time configurations is work-in-progress, so for these configurations, the public API only makes the 32-bit time support available. In a later change, the public API will allow user code to choose the time size for a given compilation unit." - compiling with -D_TIME_BITS=64 currently has no effect - glibc recent (Jul 2021) mailing list discussion - https://public-inbox.org/bug-gnulib/878s2ozq70.fsf@oldenburg.str.redhat.com/T/ - FreeBSD i386 - DragonFlyBSD 32-bit * Y2038 mitigations attempted on Y2038-UNSAFE platforms (32-bit signed time_t) * lighttpd prefers system monotonic clock instead of realtime clock in places where realtime clock is not required * lighttpd treats negative time_t values as after 19 Jan 2038 03:14:07 GMT * (lighttpd presumes that lighttpd will not encounter dates before 1970 during normal operation.) * lighttpd casts struct stat st.st_mtime (and st.st_*time) through uint64_t to convert negative timestamps for comparisions with 64-bit timestamps (treating negative timestamp values as after 19 Jan 2038 03:14:07 GMT) * lighttpd provides unix_time64_t (int64_t) and * lighttpd provides struct unix_timespec64 (unix_timespec64_t) (struct timespec equivalent using unix_time64_t tv_sec member) * lighttpd provides gmtime64_r() and localtime64_r() wrappers for platforms 32-bit platforms using 32-bit time_t and lighttpd temporarily shifts the year in order to use gmtime_r() and localtime_r() (or gmtime() and localtime()) from standard libraries, before readjusting year and passing struct tm to formatting functions such as strftime() * lighttpd provides TIME64_CAST() macro to cast signed 32-bit time_t to unsigned 32-bit and then to unix_time64_t * Note: while lighttpd tries handle times past 19 Jan 2038 03:14:07 GMT on 32-bit platforms using 32-bit signed time_t, underlying libraries and underlying filesystems might not behave properly after 32-bit signed time_t overflows (19 Jan 2038 03:14:08 GMT). If a given 32-bit OS does not work properly using negative time_t values, then lighttpd likely will not work properly on that system. * Other references and blogs - https://en.wikipedia.org/wiki/Year_2038_problem - https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs - http://www.lieberbiber.de/2017/03/14/a-look-at-the-year-20362038-problems-and-time-proofness-in-various-systems/
* [multiple] buffer_copy_string_len_lc()Glenn Strauss2021-08-271-2/+1
| | | | | | | convenience wrapper combining buffer_copy_string_len() buffer_to_lower() and making a single pass over string
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-27/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg
* [TLS] write_cq_ssl defer remove_finished_chunksGlenn Strauss2021-08-271-8/+12
| | | | | | not expecting 0-length chunks, but handle within loops as cold path mark some cold paths in read_cq_ssl and write_cq_ssl callback funcs
* [mod_auth*] rename http_auth.* -> mod_auth_api.*Glenn Strauss2021-08-271-1/+1
| | | | rename http_auth.[ch] -> mod_auth_api.[ch]
* [multiple] rename safe_memclear() -> ck_memzero()Glenn Strauss2021-08-271-5/+5
|
* [multiple] mark con->srv_socket a const ptrGlenn Strauss2021-05-131-1/+1
|
* [TLS] ALPN h2 policyGlenn Strauss2021-05-061-1/+32
| | | | | | | | | | | | | | | | | | | HTTP/2 requires that TLS protocol >= TLSv1.2 HTTP/2 requires that TLS record compression be disabled HTTP/2 requires that TLSv1.2 renegotiation be disabled HTTP/2 requires that TLS SNI extension be presented with ALPN h2 (not enforced; SNI omitted by client when connecting to IP instead of to name) RFC 7540 9.2 Use of TLS Features "Implementations are encouraged to provide defaults that comply, but it is recognized that deployments are ultimately responsible for compliance." If TLS record compression or renegotiation are for some reason required (which is strongly discouraged), then disable HTTP/2 in lighttpd with server.feature-flags = ("server.h2proto" => "disable")
* [multiple] quiet coverity warningsGlenn Strauss2021-04-071-1/+1
| | | | | includes rejigger of some code in buffer.c for Coverity to have better visibility into what is happening in internal, private funcs
* [TLS] rename ssl.verifyclient.ca-*file optionsGlenn Strauss2021-04-061-2/+34
| | | | | | | | | rename to reflect use for verifying client certificate (old names are still accepted, but are discouraged) ssl.ca-file -> ssl.verifyclient.ca-file ssl.ca-dn-file -> ssl.verifyclient.ca-dn-file ssl.ca-crl-file -> ssl.verifyclient.ca-crl-file
* [multiple] buffer_copy_path_len2() aggregateGlenn Strauss2021-04-021-2/+2
|
* [multiple] pass len when copying constant stringsGlenn Strauss2021-04-021-2/+2
|
* [TLS] use stack for SSL_CLIENT_S_DN_* tagGlenn Strauss2021-03-261-7/+6
| | | | (reduce use of r->tmp_buf in TLS modules)
* [TLS] https_add_ssl_client_verify_err()Glenn Strauss2021-03-261-14/+26
| | | | | | separate routine for printing client certificate verification error more consistent SSL_CLIENT_M_SERIAL between modules
* [multiple] http_header APIs to reduce str copiesGlenn Strauss2021-03-261-49/+50
|
* [TLS] init STEK even if time is 1970 (fixes #3075)Glenn Strauss2021-03-261-1/+3
| | | | | | | | (thx DamienT) x-ref: "TLS 1.3 with SessionTicket fail for the first 8 hours of 1970" https://redmine.lighttpd.net/issues/3075
* [mod_mbedtls] preproc wrap ssl_parse_client_helloGlenn Strauss2021-02-091-0/+8
| | | | wrap ssl_parse_client_hello() with preprocessor definitions
* [mod_gnutls,mod_mbedtls] recog common cipherstringGlenn Strauss2021-02-051-0/+2
| | | | | | | | recognize and translate a common recommended cipherstring "ECDHE+AESGCM:ECDHE+AES256:CHACHA20:!SHA1:!SHA256:!SHA384" (basically: ECDHE+AESGCM:ECDHE+AES256:CHACHA20 without CBC ciphers reported as weak by SSLLabs)
* [mod_mbedtls] remove redundant condition checkGlenn Strauss2021-02-021-7/+1
| | | | (identified by coverity)
* [mod_mbedtls] restore ALPN chk after client helloGlenn Strauss2021-02-011-0/+49
| | | | | | | | (removed two commits ago) must check selected ALPN after client hello has completed for case where hctx->conf.ssl_acme_tls_1 is not enabled or else ALPN "h2" will not be detected