Commit Graph

136 Commits (81e4f4c4a7ce25ba6173d7020b20140559f8ad01)

Author SHA1 Message Date
Glenn Strauss bdb3040f14 [mod_openssl] use SSL_OP_NO_RENEGOTIATION if avail
use [mod_openssl] SSL_OP_NO_RENEGOTIATION if available
(openssl 1.1.0 and later)
3 years ago
Glenn Strauss 3403382261 [mod_openssl] issue warning for deprecated options 3 years ago
Glenn Strauss d605c83a73 [mod_openssl] enable read-ahead, if set, after SNI
note: not disabling if enabled; extra blocks may already have been read
3 years ago
Glenn Strauss c18f442a63 [multiple] add summaries to top of some modules 3 years ago
Glenn Strauss acff179322 [mod_openssl] set chains from callback in 1.0.2+ (#2842)
mod_openssl leverages cert callback in openssl 1.0.2 and later
(SSL_CTX_set_cert_cb())

server certificate chain
  is now set in the cert callback

verify_store (for client certificate verification) (ssl.ca-file)
  is now set in the cert callback

more carefully load sensitive files and clear temporary storage
  (with openssl 1.1.1 and later)

x-ref:
  "Lighttpd Returns Wrong Cert In Multi-cert Set-up"
  https://redmine.lighttpd.net/issues/2842
3 years ago
Glenn Strauss 01b1f16b3f [mod_openssl] set cert from callback in 1.0.2+ (fixes #2842)
set server certificate from callback in openssl 1.0.2 and later
(SSL_CTX_set_cert_cb())

For existing versions of lighttpd, certificate selection influenced by
ssl.cipher-list which can be used to set server cipher order preference
(along with ssl.honor-cipher-order = "enable", which is the default)

x-ref:
  "Lighttpd Returns Wrong Cert In Multi-cert Set-up"
  https://redmine.lighttpd.net/issues/2842
  "lighttpd uses wrong pem-file"
  https://redmine.lighttpd.net/issues/3009
3 years ago
Glenn Strauss 2a5b7c648a [mod_openssl] rotate session ticket encryption key
server ticket encryption key (STEK) rotation occurs every 86400 seconds
and upon lighttpd server restart.  If using lighttpd with multiple
lighttpd workers, then restarting lighttpd keeps the STEK in sync
between lighttpd workers.
3 years ago
Glenn Strauss 68d626fa9f [mod_openssl] SSL_R_UNEXPECTED_EOF_WHILE_READING
report SSL_R_UNEXPECTED_EOF_WHILE_READING if debug.log-ssl-noise enabled

SSL_R_UNEXPECTED_EOF_WHILE_READING
added in openssl 1.1.1e and reverted in 1.1.1f, but kept in 3.0 branch
3 years ago
Glenn Strauss b33b6f9121 [mod_openssl] do not log ECONNRESET unless debug
do not log ECONNRESET to errorlog unless debug.log-ssl-noise = "enable"
3 years ago
Glenn Strauss ce7840504d [mod_openssl] disable cert vrfy if ALPN acme-tls/1
disable client cert verification if ALPN "acme-tls/1"
3 years ago
Glenn Strauss c752d4696e [multiple] correct misspellings in comments
x-ref:
  "Script for fixing spelling errors with codespell"
  https://redmine.lighttpd.net/boards/3/topics/8947
3 years ago
Glenn Strauss 7c7f8c467c [multiple] split con, request (very large change)
NB: r->tmp_buf == srv->tmp_buf (pointer is copied for quicker access)

NB: request read and write chunkqueues currently point to connection
    chunkqueues; per-request and per-connection chunkqueues are
    not distinct from one another
      con->read_queue  == r->read_queue
      con->write_queue == r->write_queue

NB: in the future, a separate connection config may be needed for
    connection-level module hooks.  Similarly, might need to have
    per-request chunkqueues separate from per-connection chunkqueues.
    Should probably also have a request_reset() which is distinct from
    connection_reset().
3 years ago
Glenn Strauss 100dfaa3f3 [core] move plugin_ctx into (request_st *)
NB: in the future, a separate plugin_ctx may be needed for
    connection-level plugins to keep state across multiple requests
3 years ago
Glenn Strauss 8131e4396d [core] move addtl request-specific struct members 3 years ago
Glenn Strauss 1dd58c5ad8 [multiple] con->proto_default_port 3 years ago
Glenn Strauss 034d7d6734 [core] http_request_host_policy w/ http_parseopts
pass http_parseopts arg (instead of con) to http_request_host_policy()
3 years ago
Glenn Strauss ca97505a72 [multiple] store srv->tmp_buf in tb var
rather than using srv->tmp_buf directly in code modifying temp buf (tb)
3 years ago
Glenn Strauss 0ff60d8218 [multiple] rename r to rc rv rd wr to be different
variable rename
3 years ago
Glenn Strauss 03b4c993d2 [multiple] generic config array type checking 3 years ago
Glenn Strauss b5775b9951 [multiple] reduce direct use of srv->errh 3 years ago
Glenn Strauss de73b190a4 [core] read up-to fixed size chunk before fionread 3 years ago
Glenn Strauss f24e6d696a [multiple] plugin_stats array
use global rather than passing around (server *) just for that

li_itostrn() and li_utostrn() return string length
(rather than requiring subsequent strlen() to find length)
3 years ago
Glenn Strauss 50bdb55de8 [multiple] connection hooks no longer get (srv *)
(explicit (server *) not passed; available in con->srv)
3 years ago
Glenn Strauss 010c28949c [multiple] prefer (connection *) to (srv *)
convert all log_error_write() to log_error() and pass (log_error_st *)

use con->errh in preference to srv->errh (even though currently same)

avoid passing (server *) when previously used only for logging (errh)
3 years ago
Glenn Strauss 24680a9142 [core] array_init() arg for initial size 3 years ago
Glenn Strauss b73949e03f [multiple] plugin.c handles common FREE_FUNC code
(simpler for modules; less boilerplate to cut-n-paste)
3 years ago
Glenn Strauss 83633a9f06 [mod_openssl] use config_plugin_values_init() 3 years ago
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)
4 years ago
Glenn Strauss 88ee73d0a2 [multiple] perf: simplify chunkqueue_get_memory() 4 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)
4 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/
4 years ago
Glenn Strauss 89062d8134 [mod_openssl] move SSL_shutdown() to separate func
mod_openssl_close_notify()
4 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
5 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
5 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
5 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
5 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
5 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
Glenn Strauss 78cc72726d [mod_extforward] support HAProxy "PROXY" protocol (fixes #2804)
experimental support to receive requests via HAProxy "PROXY" protocol

x-ref:
  "The PROXY protocol - Versions 1 & 2"
  http://www.haproxy.org/download/1.8/doc/proxy-protocol.txt
  "support (HAProxy) PROXY protocol for receiving requests"
  https://redmine.lighttpd.net/issues/2804
6 years ago
Glenn Strauss e33ec75999 [core] save connection-level proto in con->proto
The per-request scheme starts with con->proto (e.g. "http")
and can later be changed per-request by mod_extforward or mod_magnet
6 years ago
Glenn Strauss 1485cb401b [core] fix crash if invalid config file (fixes #2798)
If lighttpd.conf is invalid, some modules may not have initialized their
per-context config structures, but will have their free-functions
called, which should not be run on uninitialized per-context configs.

x-ref:
  "Segfault with simple-vhost.debug = "enable""
  https://redmine.lighttpd.net/issues/2798
6 years ago
Glenn Strauss 82501d24f2 [mod_openssl] inherit ssl.* from global scope
inherit ssl.* from global scope if $SERVER["socket"] contains
ssl.engine = "enable" and no other ssl.* settings

(In earlier versions of lighttpd, specifying ssl.engine = "enable"
 without specifying ssl.pemfile was a configuration error, so this
 change should not break any pre-existing and previously working
 configs)

x-ref:
  https://github.com/pfsense/FreeBSD-ports/pull/284
6 years ago
Glenn Strauss acc37c1cbc [mod_openssl] use TLS SNI to set host-based certs
and then allow HTTP Host header to set con->uri.authority

remove con->tlsext_server_name
6 years ago
Glenn Strauss 20946a8b92 [mod_openssl] allow ssl.verifyclient on url paths (fixes #2245)
re-patch mod_openssl config within the request so that per-request
settings can be applied, such as activating client cert verification
for specific URL paths.

(This can be used in conjunction with auth.backend = "extern"
 to require auth to occur)

x-ref:
  "SSL : authenticate only clients for a particular URL"
  https://redmine.lighttpd.net/issues/2245
6 years ago
Glenn Strauss 8960633dc7 [mod_openssl] move openssl config into mod_openssl
move openssl data structures and config parsing into mod_openssl
6 years ago
Glenn Strauss bdbea2aea8 [mod_openssl] move openssl code into mod_openssl
large code move, but minimal changes made to code (besides whitespace),
so that code builds

next: need to isolate openssl data structures and config parsing
6 years ago
Glenn Strauss cb9ebe9fa6 [mod_openssl] new module (preliminary layout) 6 years ago