Commit Graph

59 Commits (d23071a38ffff24460012556e409a8de392447cf)

Author SHA1 Message Date
Glenn Strauss d23071a38f [core] config_get_config_cond_info()
isolate direct use of (data_config *)
3 years ago
Glenn Strauss e2de4e581e [core] const char *name in struct plugin
put void *data (always used) as first member of struct plugin

add int nconfig member to PLUGIN_DATA

calloc() inits p->data to NULL
3 years ago
Glenn Strauss 36f64b26a1 [core] simpler config_check_cond()
optimize for common case where condition has been evaluated for
the request and a cached result exists

(also: begin isolating data_config)
3 years ago
Glenn Strauss c2238256e2 [core] inline array as part of data_array value
(instead of value being (array *))
3 years ago
Glenn Strauss 6eb34ef5ab [core] add const to callers of http_header_*_get()
(The few places where value is modified in-place were not made const)
3 years ago
Glenn Strauss 601c572c39 [core] inline buffer as part of data_string value
(instead of value being (buffer *))
3 years ago
Glenn Strauss 47a758f959 [core] inline buffer key for *_patch_connection()
handle buffer key as part of DATA_UNSET in *_patch_connection()
(instead of key being (buffer *))
3 years ago
Glenn Strauss ad9b7e009b [core] inline buffer as part of DATA_UNSET key
(instead of key being (buffer *))
3 years ago
Glenn Strauss a7a721ab43 [core] treat con->conditional_is_valid as bitfield 3 years ago
Glenn Strauss 83535bbef3 [core] differentiate array_get_* for ro and rw
array_get_element_klen() is now intended for read-only access
array_get_data_unset() is used by config processing for r/w access
array_get_buf_ptr() is used for r/w access to ds->value (string buffer)
3 years ago
Glenn Strauss fa8856757c [mod_openssl] reject invalid ALPN 3 years ago
Glenn Strauss 1a325a196c [mod_openssl] use SSL_CTX_set_client_hello_cb()
use SSL_CTX_set_client_hello_cb() when available

(obsoletes SSL_CTX_set_tlsext_servername_callback()
 and SSL_CTX_set_tlsext_servername_arg())
4 years ago
Mohammed Sadiq 6a988bb0d0 [multiple] cleaner calloc use in SETDEFAULTS_FUNC
github: closes #99

x-ref:
  "cleaner calloc use in SETDEFAULTS_FUNC"
  https://github.com/lighttpd/lighttpd1.4/pull/99
4 years ago
Glenn Strauss 99f8ae0d0d [mod_openssl] use 16k static buffer instead of 64k
better match size used by openssl
(avoid unused, oversized reads)
4 years ago
Glenn Strauss 8efa6a34f4 [mod_openssl] default: ssl.cipher-list = "HIGH" 4 years ago
Glenn Strauss 3e200717cc [mod_openssl] inherit cipherlist from global scope
inherit cipherlist from global scope if not set in $SERVER["socket"]
4 years ago
Glenn Strauss 1542e44bb7 [core] use openssl to read,discard request body
use openssl to read,discard request body after response has been sent
on a TLS connection, at least until SSL close notify has been sent

x-ref:
  "HTTPS POST upload hangs when i reach maximum supported request size"
  https://redmine.lighttpd.net/boards/2/topics/8491
4 years ago
Glenn Strauss 2769f19ad3 [mod_openssl] ssl.privkey directive (optional)
ssl.privkey can be used to specify path to file containing private key
in lieu of concatenating certificate and private key into single .pem
4 years ago
Glenn Strauss b17d3c2407 [mod_openssl] ALPN and acme-tls/1 (fixes #2931)
ssl.acme-tls-1 = "/path/to/dir" containing .crt.pem and .key.pem
named with the SNI name ("<SNI>.crt.pem" and "<SNI>.key.pem")

x-ref:
  "Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension"
  https://tools.ietf.org/html/rfc7301
  "ACME TLS ALPN Challenge Extension" (TLS-ALPN-01)
  https://tools.ietf.org/html/draft-ietf-acme-tls-alpn-05
  "Support for TLS-ALPN-01"
  https://redmine.lighttpd.net/issues/2931
4 years ago
Glenn Strauss cef6ee675d [core] limit con->uri.authority < 1024 octets
(expect < 256 octets for DNS name)

Since limit is imposed, can use buffer_clear() instead of buffer_reset()
for con->uri.authority and con->server_name.  (Also, con->uri.scheme is
limited to "http" and "https", so use buffer_clear() for it, too)
5 years ago
Glenn Strauss 88ee73d0a2 [multiple] perf: simplify chunkqueue_get_memory() 5 years ago
Glenn Strauss a1cda77f9b [mod_openssl] prefer using TLS_server_method()
prefer TLS_server_method() instead of SSLv23_server_method()
(SSLv23_server_method() is deprecated in openssl 1.1.0)
5 years ago
Glenn Strauss d182e90bb1 [mod_openssl] SSL_read before second SSL_shutdown
call SSL_read() before calling SSL_shutdown() a second time.

Drain SSL read buffers in case pending records need processing.

x-ref:
  "New session ticket breaks bidirectional shutdown of TLS 1.3 connection"
  https://github.com/openssl/openssl/issues/6262
  reported to lighttpd by intexk
  https://www.lighttpd.net/2018/10/14/1.4.51/
5 years ago
Glenn Strauss 89062d8134 [mod_openssl] move SSL_shutdown() to separate func
mod_openssl_close_notify()
5 years ago
Glenn Strauss 082b485802 [mod_openssl] wolfSSL does not support SSLv2 5 years ago
Glenn Strauss 0074b6d342 [mod_openssl] add support for wolfSSL
requires wolfSSL library version 3.15.3 or later
https://www.wolfssl.com/
https://github.com/wolfSSL/wolfssl

(thx dgarske)

x-ref:
  "Adds support for building Lighttpd with wolfSSL"
  https://github.com/lighttpd/lighttpd1.4/pull/92
5 years ago
Glenn Strauss 7a7f4f987a [mod_openssl] no renegotiation in TLS 1.3 (fixes #2912)
x-ref:
  "OpenSSL 1.1.1: renegotiation initiated by client, killing connection"
  https://redmine.lighttpd.net/issues/2912
5 years ago
Glenn Strauss 3dd3cde902 [core] abstraction layer for HTTP header manip
http_header.[ch]
convert existing calls to manip request/response headers
convert existing calls to manip environment array (often header-related)
5 years ago
Glenn Strauss a7c27c9f99 [core] code reuse with array_insert_key_value()
code reuse with array_insert_key_value() and related array manipulation
5 years ago
Glenn Strauss 76b9b1fa46 [mod_openssl] elliptic curve auto selection (fixes #2833)
elliptic curve auto selection where available
openssl v1.0.2 - SSL_CTX_set_ecdh_auto()
openssl v1.1.0 - ECDH support always enabled

x-ref:
  "Using X25519 Key exchange"
  https://redmine.lighttpd.net/issues/2833

  "SSL_CTX_set_ecdh_auto is undefined for newer openssl's"
  https://github.com/openssl/openssl/issues/1437
  It has been removed from OpenSSL 1.1.0.
  Here is the relevant CHANGES entry:
  *) SSL_{CTX_}set_ecdh_auto() has been removed and ECDH is support is
     always enabled now.  If you want to disable the support you should
     exclude it using the list of supported ciphers. This also means
     that the "-no_ecdhe" option has been removed from s_server.
     [Kurt Roeckx]
5 years ago
Glenn Strauss f90ccdef51 [mod_openssl] minor code cleanup; reduce var scope
('git show -u -b -w <commit-sha>' to see minimal changes)
5 years ago
Glenn Strauss 06d108855d [mod_openssl] quiet trace from TCP probes (#2784)
x-ref:
  "huge amount of "SSL: -1 5 0 Success" messages"
  https://redmine.lighttpd.net/issues/2784
6 years ago
Glenn Strauss c09acbeb8a [mod_openssl] ssl.openssl.ssl-conf-cmd (fixes #2758)
(similar to Apache mod_ssl SSLOpenSSLConfCmd directive)

(experimental)

This new directive is for use with OpenSSL only, and is not currently
available in LibreSSL.

https://wiki.openssl.org/index.php/Manual:SSL_CONF_cmd(3)

lighttpd takes "file commands" not "command line commands" as
openssl SSL_CONF_cmd() appears to permit only one mode at a time.

lighttpd processes this directive after all other ssl.* directives
have been applied for the $SERVER["socket"] scope.

x-ref:
  "Option to disable TLS session tickets"
  https://redmine.lighttpd.net/issues/2758
  "Allow to selectively disable TLS 1.0, 1.1 and 1.2 versions"
  https://github.com/lighttpd/lighttpd1.4/pull/84

github: closes #84
6 years ago
Glenn Strauss 1a22ca87f9 [mod_openssl] allow specifying server cert chain (fixes #2692)
x-ref:
  "allow setting explicit SSL server certificate chain"
  https://redmine.lighttpd.net/issues/2692
  https://github.com/lighttpd/lighttpd1.4/pull/62

github: closes #62
6 years ago
Glenn Strauss 35ecd4dd9d [mod_openssl] more pedantic check of return values
more pedantic check of return values for openssl interfaces

(and minor adjustment of whitespace)

x-ref:
  https://redmine.lighttpd.net/issues/2692
  https://github.com/lighttpd/lighttpd1.4/pull/62
6 years ago
Glenn Strauss bfef0907bd [mod_openssl] error if ssl.engine in wrong section (fixes #2837)
error if ssl.engine in wrong section of config.
ssl.engine is valid only in global scope or $SERVER["socket"] condition

x-ref:
  "HTTPS requests timeout when cert not set for socket"
  https://redmine.lighttpd.net/issues/2837
6 years ago
Glenn Strauss 77bdaa3a93 [mod_openssl] ssl.read-ahead="disable" by default
set ssl.read-ahead = "disable" by default (modifies commit f4e1357d)

Given various reports from users of embedded systems, the default is
being changed to do the sane thing for these systems.  This is the
right setting on slow embedded systems for which decoding SSL input
is slower than receiving that input over the network.

On the other hand, for faster systems, ssl.read-ahead = "enable" is
recommended for a slight performance gain and should be explicitly set
in the global or $SERVER["socket"] configuration blocks in lighttpd.conf

x-ref:
  "https POST requests buffered in RAM since v1.4.41?"
  https://redmine.lighttpd.net/boards/2/topics/7520
6 years ago
Glenn Strauss 0ff8904a72 [mod_openssl] remove erroneous SSL_set_shutdown()
remove erroneous call to SSL_set_shutdown()
(historical from commit:3888c103)
(erroneous since lighttpd 1.4.40 moved to bidirectional input/output)

x-ref:
  "wstunnel sample config"
  https://redmine.lighttpd.net/boards/2/topics/7600
6 years ago
Glenn Strauss 7661587f01 [mod_openssl] copy data for larger SSL packets
copy small mem chunks into single large buffer before SSL_write()
to reduce number times write() called underneath SSL_write() and
potentially reduce number of packets generated if socket TCP_NODELAY
6 years ago
Glenn Strauss f4e1357df5 [mod_openssl] ssl.read-ahead="disable" for stream
set default ssl.read-ahead = "disable" for streaming when
server.stream-request-body = 1 or 2 is set in the global scope

It is still recommended that embedded and other low-memory systems
explicitly set ssl.read-ahead = "disable" in the global scope
(regardless of server.stream-request-body setting)

On the other hand, for systems which enable server.stream-request-body
to non-zero value, and for which sufficient memory is available, then
ssl.read-ahead = "enable" is recommended and should be explicitly set
in the global or $SERVER["socket"] configuration blocks in lighttpd.conf

x-ref:
  "https POST requests buffered in RAM since v1.4.41?"
  https://redmine.lighttpd.net/boards/2/topics/7520
6 years ago
Glenn Strauss b50aa2df51 quell compiler warnings for -Wimplicit-fallthrough 6 years ago
Glenn Strauss 9fd39690be [mod_openssl] adjust use of ssl.ca-dn-file
ssl.ca-dn-file is used to send list of valid CA DNs to client for client
cert verification.  If ssl.ca-dn-file is not specified, then the CAs in
ssl.ca-file are used.

client certs are validated against the set of certs from both
ssl.ca-dn-file and ssl.ca-file, but issuer of cert provided by
client must be in ssl.ca-dn-file if ssl.ca-dn-file is specified.

(certs should not need to be in to both ssl.ca-file and ssl.ca-dn-file)

(thx m4t)
6 years ago
Glenn Strauss 8af9e71ccc [core] allow earlier plugin init for SSL/TLS
If lighttpd is started privileged, then SSL/TLS modules need to be
initialized prior to chroot (optional) and prior to dropping privileges
in order to be able to read sensitive files such as private certificates

(thx m4t)
6 years ago
Glenn Strauss fb87ae8604 [mod_openssl] safer_X509_NAME_oneline() (fixes #2693)
provide a safer X590_NAME_oneline() with return value semantics similar
to those of snprintf() and use safer_X509_NAME_oneline() to set
SSL_CLIENT_S_DN when client cert is validated.

The manpage for X509_NAME_oneline() says:

    The functions X509_NAME_oneline() and X509_NAME_print() are legacy functions which produce a non standard output form, they don't handle multi character fields and have various quirks and inconsistencies. Their use is strongly discouraged in new applications.

Besides X509_NAME_oneline() function being deprecated, until fairly recently, there was a security issue with the function, too.

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2176

    The X509_NAME_oneline function in crypto/x509/x509_obj.c in OpenSSL before 1.0.1t and 1.0.2 before 1.0.2h allows remote attackers to obtain sensitive information from process stack memory or cause a denial of service (buffer over-read) via crafted EBCDIC ASN.1 data.

github: closes #63, closes #83

x-ref:
  "support SSL_CLIENT_VERIFY & SSL_CLIENT_S_DN"
  https://redmine.lighttpd.net/issues/2693
  https://github.com/lighttpd/lighttpd1.4/pull/63
  https://github.com/lighttpd/lighttpd1.4/pull/83
6 years ago
Glenn Strauss 21081c7b72 [mod_openssl] fix compile with openssl 1.1.0
fix compile with openssl 1.1.0
remove stray tabs from prior commit

(thx gazoo74)
6 years ago
Gaël PORTAY 04d510af20 [mod_openssl] ignore client verification error if not enforced
ignore client verification error if not enforced
  e.g. *not* ssl.verifyclient.enforce = "enable"

github: closes #83

x-ref:
  "ignore client verification error if not enforced"
  https://github.com/lighttpd/lighttpd1.4/pull/83
6 years ago
Glenn Strauss 0399609ac2 [mod_openssl] ssl.ca-dn-file (fixes #2694)
(original patch by mackyle)

The ssl.ca-dn-file option provides independent control of
the "certificate_authorities" field (see RFC 5246 section
7.4.4 Certificate Request) separate from the actual list
of trusted certificate authorities used for client
certificate verification.

It may be necessary to send a hint that includes the DN
of a non-root client CA in order to receive the correct
certificate from the client, but such a non-root CA really
does not belong in the trusted client root CA list.

Signed-off-by: Kyle J. McKay mackyle@gmail.com

github: closes #64

x-ref:
  "add support for ssl.cadn-file"
  https://redmine.lighttpd.net/issues/2694
  https://github.com/lighttpd/lighttpd1.4/pull/64
6 years ago
Gaël PORTAY e422ac128a [mod_openssl] ssl.ca-crl-file for CRL (fixes #2319)
(original patch by binbrain, and updated by flynn)

github: closes #82

x-ref:
  "Support CRLs for client certificate verification"
  https://redmine.lighttpd.net/issues/2319
  https://github.com/lighttpd/lighttpd1.4/pull/82
6 years ago
Glenn Strauss 86bb8be2c8 [core] perf: skip redundant strlen() if len known
performance: skip redundant strlen() if length is already known

introduce array_get_element_klen() to take key and klen params
6 years ago
Glenn Strauss a434a3fab0 [mod_openssl] free local_send_buffer at exit 6 years ago