aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_ssl_module.c
Commit message (Collapse)AuthorAge
* SNI: added restriction for TLSv1.3 cross-SNI session resumption.Sergey Kandaurov2025-02-05
| | | | | | | | | | | | | | | | | In OpenSSL, session resumption always happens in the default SSL context, prior to invoking the SNI callback. Further, unlike in TLSv1.2 and older protocols, SSL_get_servername() returns values received in the resumption handshake, which may be different from the value in the initial handshake. Notably, this makes the restriction added in b720f650b insufficient for sessions resumed with different SNI server name. Considering the example from b720f650b, previously, a client was able to request example.org by presenting a certificate for example.org, then to resume and request example.com. The fix is to reject handshakes resumed with a different server name, if verification of client certificates is enabled in a corresponding server configuration.
* SSL: caching certificates and certificate keys with variables.Sergey Kandaurov2025-01-17
| | | | | | | | A new directive "ssl_certificate_cache max=N [valid=time] [inactive=time]" enables caching of SSL certificate chain and secret key objects specified by "ssl_certificate" and "ssl_certificate_key" directives with variables. Co-authored-by: Aleksei Bavshin <a.bavshin@nginx.com>
* SSL: a new macro to set default protocol versions.Sergey Kandaurov2024-11-22
| | | | | | | | | This simplifies merging protocol values after ea15896 and ebd18ec. Further, as outlined in ebd18ec18, for libraries preceeding TLSv1.2+ support, only meaningful versions TLSv1 and TLSv1.1 are set by default. While here, fixed indentation.
* SSL: fixed MSVC compilation after ebd18ec1812b.蕭澧邦2024-11-11
| | | | | MSVC generates a compilation error in case #if/#endif is used in a macro parameter.
* SSL: disabled TLSv1 and TLSv1.1 by default.Sergey Kandaurov2024-10-31
| | | | | | | | | | | | | | | TLSv1 and TLSv1.1 are formally deprecated and forbidden to negotiate due to insufficient security reasons outlined in RFC 8996. TLSv1 and TLSv1.1 are disabled in BoringSSL e95b0cad9 and LibreSSL 3.8.1 in the way they cannot be enabled in nginx configuration. In OpenSSL 3.0, they are only permitted at security level 0 (disabled by default). The support is dropped in Chrome 84, Firefox 78, and deprecated in Safari. This change disables TLSv1 and TLSv1.1 by default for OpenSSL 1.0.1 and newer, where TLSv1.2 support is available. For older library versions, which do not have alternatives, these protocol versions remain enabled.
* SSL: optional ssl_client_certificate for ssl_verify_client.Sergey Kandaurov2024-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | Starting from TLSv1.1 (as seen since draft-ietf-tls-rfc2246-bis-00), the "certificate_authorities" field grammar of the CertificateRequest message was redone to allow no distinguished names. In TLSv1.3, with the restructured CertificateRequest message, this can be similarly done by optionally including the "certificate_authorities" extension. This allows to avoid sending DNs at all. In practice, aside from published TLS specifications, all supported SSL/TLS libraries allow to request client certificates with an empty DN list for any protocol version. For instance, when operating in TLSv1, this results in sending the "certificate_authorities" list as a zero-length vector, which corresponds to the TLSv1.1 specification. Such behaviour goes back to SSLeay. The change relaxes the requirement to specify at least one trusted CA certificate in the ssl_client_certificate directive, which resulted in sending DNs of these certificates (closes #142). Instead, all trusted CA certificates can be specified now using the ssl_trusted_certificate directive if needed. A notable difference that certificates specified in ssl_trusted_certificate are always loaded remains (see 3648ba7db). Co-authored-by: Praveen Chaudhary <praveenc@nvidia.com>
* Stream: OCSP stapling.Sergey Kandaurov2024-08-22
|
* Stream: client certificate validation with OCSP.Sergey Kandaurov2024-08-22
|
* Stream: using ngx_stream_ssl_srv_conf_t *sscf naming convention.Sergey Kandaurov2024-03-22
| | | | | | | | Originally, the stream module was developed based on the mail module, following the existing style. Then it was diverged to closely follow the http module development. This change updates style to use sscf naming convention troughout the stream module, which matches the http module code style. No functional changes.
* Stream: virtual servers.Roman Arutyunyan2023-12-14
| | | | | | | | | Server name is taken either from ngx_stream_ssl_module or ngx_stream_ssl_preread_module. The change adds "default_server" parameter to the "listen" directive, as well as the following directives: "server_names_hash_max_size", "server_names_hash_bucket_size", "server_name" and "ssl_reject_handshake".
* SSL: enabled TLSv1.3 by default.Maxim Dounin2023-03-24
|
* SSL: improved validation of ssl_session_cache and ssl_ocsp_cache.Sergey Kandaurov2022-10-17
| | | | | | | Now it properly detects invalid shared zone configuration with omitted size. Previously it used to read outside of the buffer boundary. Found with AddressSanitizer.
* SSL: $ssl_curve (ticket #2135).Sergey Kandaurov2021-11-01
| | | | | | | | | | | | | | | The variable contains a negotiated curve used for the handshake key exchange process. Known curves are listed by their names, unknown ones are shown in hex. Note that for resumed sessions in TLSv1.2 and older protocols, $ssl_curve contains the curve used during the initial handshake, while in TLSv1.3 it contains the curve used during the session resumption (see the SSL_get_negotiated_group manual page for details). The variable is only meaningful when using OpenSSL 3.0 and above. With older versions the variable is empty.
* Style: added missing "static" specifiers.Maxim Dounin2021-10-21
| | | | | Mostly found by gcc -Wtraditional, per "non-static declaration of ... follows static declaration [-Wtraditional]" warnings.
* Stream: the "ssl_alpn" directive.Vladimir Homutov2021-10-19
| | | | | | The directive sets the server list of supported application protocols and requires one of this protocols to be negotiated if client is using ALPN.
* SSL: added $ssl_alpn_protocol variable.Vladimir Homutov2021-10-14
| | | | | The variable contains protocol selected by ALPN during handshake and is empty otherwise.
* SSL: ciphers now set before loading certificates (ticket #2035).Maxim Dounin2021-08-16
| | | | | | | To load old/weak server or client certificates it might be needed to adjust the security level, as introduced in OpenSSL 1.1.0. This change ensures that ciphers are set before loading the certificates, so security level changes via the cipher string apply to certificate loading.
* SSL: fixed build by Sun C with old OpenSSL versions.Maxim Dounin2021-03-05
| | | | | Sun C complains about "statement not reached" if a "return" is followed by additional statements.
* SSL: ssl_conf_command directive.Maxim Dounin2020-10-22
| | | | | | | | | | | | | | | | | | | | | | | | | With the ssl_conf_command directive it is now possible to set arbitrary OpenSSL configuration parameters as long as nginx is compiled with OpenSSL 1.0.2 or later. Full list of available configuration commands can be found in the SSL_CONF_cmd manual page (https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html). In particular, this allows configuring PrioritizeChaCha option (ticket #1445): ssl_conf_command Options PrioritizeChaCha; It can be also used to configure TLSv1.3 ciphers in OpenSSL, which fails to configure them via the SSL_CTX_set_cipher_list() interface (ticket #1529): ssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256; Configuration commands are applied after nginx own configuration for SSL, so they can be used to override anything set by nginx. Note though that configuring OpenSSL directly with ssl_conf_command might result in a behaviour nginx does not expect, and should be done with care.
* SSL: fixed ssl_verify_client error message.Sergey Kandaurov2019-09-16
|
* SSL: fixed potential leak on memory allocation errors.Maxim Dounin2019-03-03
| | | | | | | | | If ngx_pool_cleanup_add() fails, we have to clean just created SSL context manually, thus appropriate call added. Additionally, ngx_pool_cleanup_add() moved closer to ngx_ssl_create() in the ngx_http_ssl_module, to make sure there are no leaks due to intermediate code.
* SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.Maxim Dounin2019-03-03
| | | | | | | | | | | | | | OpenSSL 1.1.1 does not save server name to the session if server name callback returns anything but SSL_TLSEXT_ERR_OK, thus breaking the $ssl_server_name variable in resumed sessions. Since $ssl_server_name can be used even if we've selected the default server and there are no other servers, it looks like the only viable solution is to always return SSL_TLSEXT_ERR_OK regardless of the actual result. To fix things in the stream module as well, added a dummy server name callback which always returns SSL_TLSEXT_ERR_OK.
* SSL: fixed possible segfault with dynamic certificates.Maxim Dounin2019-02-25
| | | | | | | | | | A virtual server may have no SSL context if it does not have certificates defined, so we have to use config of the ngx_http_ssl_module from the SSL context in the certificate callback. To do so, it is now passed as the argument of the callback. The stream module doesn't really need any changes, but was modified as well to match http code.
* SSL: adjusted session id context with dynamic certificates.Maxim Dounin2019-02-25
| | | | | | | | | | | | Dynamic certificates re-introduce problem with incorrect session reuse (AKA "virtual host confusion", CVE-2014-3616), since there are no server certificates to generate session id context from. To prevent this, session id context is now generated from ssl_certificate directives as specified in the configuration. This approach prevents incorrect session reuse in most cases, while still allowing sharing sessions across multiple machines with ssl_session_ticket_key set as long as configurations are identical.
* SSL: dynamic certificate loading in the stream module.Maxim Dounin2019-02-25
|
* SSL: detect "listen ... ssl" without certificates (ticket #178).Maxim Dounin2018-04-24
| | | | | | | | | In mail and stream modules, no certificate provided is a fatal condition, much like with the "ssl" and "starttls" directives. In http, "listen ... ssl" can be used in a non-default server without certificates as long as there is a certificate in the default one, so missing certificate is only fatal for default servers.
* SSL: using default server context in session remove (closes #1464).Sergey Kandaurov2018-01-30
| | | | | This fixes segfault in configurations with multiple virtual servers sharing the same port, where a non-default virtual server block misses certificate.
* SSL: the $ssl_client_escaped_cert variable (ticket #857).Maxim Dounin2017-08-22
| | | | | | | | | | | | This variable contains URL-encoded client SSL certificate. In contrast to $ssl_client_cert, it doesn't depend on deprecated header continuation. The NGX_ESCAPE_URI_COMPONENT variant of encoding is used, so the resulting variable can be safely used not only in headers, but also as a request argument. The $ssl_client_cert variable should be considered deprecated now. The $ssl_client_raw_cert variable will be eventually renambed back to $ssl_client_cert.
* Variables: macros for null variables.Ruslan Ermilov2017-08-01
| | | | No functional changes.
* Style: changed checks of ngx_ssl_create_connection() to != NGX_OK.Maxim Dounin2017-05-29
| | | | | | In http these checks were changed in a6d6d762c554, though mail module was missed at that time. Since then, the stream module was introduced based on mail, using "== NGX_ERROR" check.
* SSL: set TCP_NODELAY on SSL connections before handshake.Maxim Dounin2017-05-29
| | | | | | | | | | | | With OpenSSL 1.1.0+, the workaround for handshake buffer size as introduced in a720f0b0e083 (ticket #413) no longer works, as OpenSSL no longer exposes handshake buffers, see https://github.com/openssl/openssl/commit/2e7dc7cd688. Moreover, it is no longer possible to adjust handshake buffers at all now. To avoid additional RTT if handshake uses more than 4k we now set TCP_NODELAY on SSL connections before handshake. While this still results in sub-optimal network utilization due to incomplete packets being sent, it seems to be better than nothing.
* SSL: added support for TLSv1.3 in ssl_protocols directive.Sergey Kandaurov2017-04-18
| | | | Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
* Stream: client SSL certificates were not checked in some cases.Vladimir Homutov2017-01-19
| | | | | | | If ngx_stream_ssl_init_connection() succeeded immediately, the check was not done. The bug had appeared in 1.11.8 (41cb1b64561d).
* Stream: fixed handling of non-ssl sessions.Vladimir Homutov2017-01-19
| | | | | | | | A missing check could cause ngx_stream_ssl_handler() to be applied to a non-ssl session, which resulted in a null pointer dereference if ssl_verify_client is enabled. The bug had appeared in 1.11.8 (41cb1b64561d).
* Stream: client SSL certificates verification support.Vladimir Homutov2016-12-20
| | | | | | | | | | | New directives: "ssl_verify_client", "ssl_verify_depth", "ssl_client_certificate", "ssl_trusted_certificate", and "ssl_crl". New variables: $ssl_client_cert, $ssl_client_raw_cert, $ssl_client_s_dn, $ssl_client_i_dn, $ssl_client_serial, $ssl_client_fingerprint, $ssl_client_verify, $ssl_client_v_start, $ssl_client_v_end, and $ssl_client_v_remain.
* SSL: $ssl_curves (ticket #1088).Maxim Dounin2016-12-05
| | | | | | | | | | | | | | The variable contains a list of curves as supported by the client. Known curves are listed by their names, unknown ones are shown in hex, e.g., "0x001d:prime256v1:secp521r1:secp384r1". Note that OpenSSL uses session data for SSL_get1_curves(), and it doesn't store full list of curves supported by the client when serializing a session. As a result $ssl_curves is only available for new sessions (and will be empty for reused ones). The variable is only meaningful when using OpenSSL 1.0.2 and above. With older versions the variable is empty.
* SSL: $ssl_ciphers (ticket #870).Maxim Dounin2016-12-05
| | | | | | | | | | | | | | The variable contains list of ciphers as supported by the client. Known ciphers are listed by their names, unknown ones are shown in hex, e.g., ""AES128-SHA:AES256-SHA:0x00ff". The variable is fully supported only when using OpenSSL 1.0.2 and above. With older version there is an attempt to provide some information using SSL_get_shared_ciphers(). It only lists known ciphers though. Moreover, as OpenSSL uses session data for SSL_get_shared_ciphers(), and it doesn't store relevant data when serializing a session. As a result $ssl_ciphers is only available for new sessions (and not available for reused ones) when using OpenSSL older than 1.0.2.
* Stream: phases.Roman Arutyunyan2016-09-15
|
* Stream: SSL-related variables.Vladimir Homutov2016-06-29
|
* Stream: added preconfiguration step.Vladimir Homutov2016-06-15
|
* SSL: ngx_ssl_ciphers() to set list of ciphers.Tim Taubert2016-06-15
| | | | | | This patch moves various OpenSSL-specific function calls into the OpenSSL module and introduces ngx_ssl_ciphers() to make nginx more crypto-library-agnostic.
* SSL: support for multiple curves (ticket #885).Maxim Dounin2016-05-19
| | | | | | | | | | | | | | | | | | OpenSSL 1.0.2+ allows configuring a curve list instead of a single curve previously supported. This allows use of different curves depending on what client supports (as available via the elliptic_curves extension), and also allows use of different curves in an ECDHE key exchange and in the ECDSA certificate. The special value "auto" was introduced (now the default for ssl_ecdh_curve), which means "use an internal list of curves as available in the OpenSSL library used". For versions prior to OpenSSL 1.0.2 it maps to "prime256v1" as previously used. The default in 1.0.2b+ prefers prime256v1 as well (and X25519 in OpenSSL 1.1.0+). As client vs. server preference of curves is controlled by the same option as used for ciphers (SSL_OP_CIPHER_SERVER_PREFERENCE), the ssl_prefer_server_ciphers directive now controls both.
* SSL: support for multiple certificates (ticket #814).Maxim Dounin2016-05-19
|
* SSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.Maxim Dounin2016-03-31
| | | | OpenSSL removed support for all 40 and 56 bit ciphers.
* Stream: avoid SSL_CTX_set_tmp_rsa_callback() call with LibreSSL.Piotr Sikora2015-06-18
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Stream: added postconfiguration method to stream modules.Vladimir Homutov2015-06-09
|
* Disabled SSLv3 by default (ticket #653).Maxim Dounin2015-05-25
|
* Stream: port from NGINX+.Ruslan Ermilov2015-04-20