Commit Graph

8445 Commits

Author SHA1 Message Date
Sergey Kandaurov 78d1ab5a2c SSL: support for compressed server certificates with BoringSSL.
BoringSSL/AWS-LC provide two callbacks for each compression algorithm,
which may be used to compress and decompress certificates in runtime.
This change implements compression support with zlib, as enabled with
the ssl_certificate_compression directive.  Compressed certificates
are stored in certificate exdata and reused in subsequent connections.

Notably, AWS-LC saves an X509 pointer in SSL connection, which allows
to use it from SSL_get_certificate() for caching purpose.  In contrast,
BoringSSL reconstructs X509 on-the-fly, though given that it doesn't
support multiple certificates, always replacing previously configured
certificates, we use the last configured one from ssl->certs, instead.
2025-10-08 19:56:41 +04:00
Sergey Kandaurov 25b03d6500 SSL: disabled using certificate compression with OCSP stapling.
OCSP response in TLSv1.3 is sent in the Certificate message.  This
is incompatible with pre-compression of the configured certificates.
2025-10-08 19:56:41 +04:00
Sergey Kandaurov f5a989cda2 Updated OpenSSL and PCRE used for win32 builds. 2025-10-08 19:56:41 +04:00
Sergey Kandaurov 3494f25c3e Version bump. 2025-10-08 19:56:41 +04:00
Sergey Kandaurov 7f71abdd14 nginx-1.29.2-RELEASE 2025-10-07 21:04:07 +04:00
Sergey Kandaurov 9d5cdc616c Fixed a typo. 2025-10-07 21:04:07 +04:00
Sergey Kandaurov a144d828cb SSL: fixed "key values mismatch" with object cache inheritance.
In rare cases, it was possible to get into this error state on reload
with improperly updated file timestamps for certificate and key pairs.

The fix is to retry on X509_R_KEY_VALUES_MISMATCH, similar to 5d5d9adcc.
Additionally, loading SSL certificate is updated to avoid certificates
discarded on retry to appear in ssl->certs and in extra chain.
2025-10-06 12:56:42 +04:00
Maryna-f5 c2a266fa78 Added F5 CLA workflow. 2025-09-30 11:44:52 -07:00
Sergey Kandaurov 6f81314a07 Mail: xtext encoding (RFC 3461) in XCLIENT LOGIN.
The XCLIENT command uses xtext encoding for attribute values,
as specified in https://www.postfix.org/XCLIENT_README.html.

Reported by Igor Morgenstern of Aisle Research.
2025-09-26 17:04:20 +04:00
Sergey Kandaurov 8255bd29ac Upstream: overflow detection in Cache-Control delta-seconds.
Overflowing calculations are now aligned to the greatest positive integer
as specified in RFC 9111, Section 1.2.2.
2025-09-26 16:50:13 +04:00
Sergey Kandaurov 93ff1ee12c SSL: AWS-LC compatibility. 2025-09-25 19:28:36 +04:00
Sergey Kandaurov af436c58ca QUIC: a new macro to differentiate BoringSSL specific EVP API. 2025-09-25 19:28:36 +04:00
Sergey Kandaurov 4c9ae11dff QUIC: localized OpenSSL headers used for QUIC protection. 2025-09-25 19:28:36 +04:00
Sergey Kandaurov 7f9ced0ce0 SNI: support for early ClientHello callback with BoringSSL.
This brings feature parity with OpenSSL after the previous change,
making it possible to set SSL protocols per virtual server.
2025-09-25 19:25:08 +04:00
Sergey Kandaurov 0373fe5d98 SNI: using the ClientHello callback.
The change introduces an SNI based virtual server selection during
early ClientHello processing.  The callback is available since
OpenSSL 1.1.1; for older OpenSSL versions, the previous behaviour
is kept.

Using the ClientHello callback sets a reasonable processing order
for the "server_name" TLS extension.  Notably, session resumption
decision now happens after applying server configuration chosen by
SNI, useful with enabled verification of client certificates, which
brings consistency with BoringSSL behaviour.  The change supersedes
and reverts a fix made in 46b9f5d38 for TLSv1.3 resumed sessions.

In addition, since the callback is invoked prior to the protocol
version negotiation, this makes it possible to set "ssl_protocols"
on a per-virtual server basis.

To keep the $ssl_server_name variable working with TLSv1.2 resumed
sessions, as previously fixed in fd97b2a80, a limited server name
callback is preserved in order to acknowledge the extension.

Note that to allow third-party modules to properly chain the call to
ngx_ssl_client_hello_callback(), the servername callback function is
passed through exdata.
2025-09-25 19:25:08 +04:00
willmafh bc71625dcc Fixed inaccurate index directive error report. 2025-09-18 18:16:22 +04:00
Sergey Kandaurov 417c87b78d Updated link to xslscript. 2025-09-15 22:13:27 +04:00
Sergey Kandaurov eb5ebbbed7 QUIC: fixed ssl_reject_handshake error handling.
This was broken in 7468a10b6 (1.29.0), resulting in a missing diagnostics
and SSL error queue not cleared for SSL handshakes rejected by SNI, seen
as "ignoring stale global SSL error" alerts, for instance, when doing SSL
shutdown of a long standing connection after rejecting another one by SNI.

The fix is to move the qc->error check after c->ssl->handshake_rejected is
handled first, to make the error queue cleared.  Although not practicably
visible as needed, this is accompanied by clearing the error queue under
the qc->error case as well, to be on the safe side.

As an implementation note, due to the way of handling invalid transport
parameters for OpenSSL 3.5 and above, which leaves a passed pointer not
advanced on error, SSL_get_error() may return either SSL_ERROR_WANT_READ
or SSL_ERROR_WANT_WRITE depending on a library.  To cope with that, both
qc->error and c->ssl->handshake_rejected checks were moved out of
"sslerr != SSL_ERROR_WANT_READ".

Also, this reconstructs a missing "SSL_do_handshake() failed" diagnostics
for the qc->error case, replacing using ngx_ssl_connection_error() with
ngx_connection_error().  It is made this way to avoid logging at the crit
log level because qc->error set is expected to have an empty error queue.

Reported and tested by Vladimir Homutov.
2025-09-12 17:57:48 +04:00
Mohamed Karrab 446ce033e5 Removed legacy charset directive from default config example.
The example configuration previously specified 'charset koi8-r',
which is a legacy Cyrillic encoding.  As koi8-r is rarely used today
and modern browsers handle UTF-8 by default, specifying the charset
explicitly is unnecessary.  Removing the directive keeps the example
configuration concise and aligned with current best practices.
2025-08-19 15:47:51 +04:00
Sergey Kandaurov 1a82df8cca Added a previously missed changes entry in 1.29.1 relnotes. 2025-08-13 21:21:40 +04:00
Sergey Kandaurov 36d40e5610 Version bump. 2025-08-13 21:21:40 +04:00
Sergey Kandaurov 0024724f2f nginx-1.29.1-RELEASE 2025-08-13 18:33:41 +04:00
Sergey Kandaurov cc1c07ca33 Updated OpenSSL used for win32 builds. 2025-08-13 18:33:41 +04:00
Sergey Kandaurov 239e10793a Mail: logging upstream to the error log with "smtp_auth none;".
Previously, it was never logged because of missing login.
2025-08-13 18:20:34 +04:00
Sergey Kandaurov 9c02c84a74 Mail: reset stale auth credentials with "smtp_auth none;".
They might be reused in a session if an SMTP client proceeded
unauthenticated after previous invalid authentication attempts.
This could confuse an authentication server when passing stale
credentials along with "Auth-Method: none".

The condition to send the "Auth-Salt" header is similarly refined.
2025-08-13 18:20:34 +04:00
Sergey Kandaurov 765642b86e Mail: improved error handling in plain/login/cram-md5 auth methods.
Previously, login and password storage could be left in inconsistent
state in a session after decoding errors.
2025-08-13 18:20:34 +04:00
Sergey Kandaurov 034f15bbc2 Auth basic: fixed file descriptor leak on memory allocation error.
Found by Coverity (CID 1662016).
2025-08-11 20:57:47 +04:00
Sergey Kandaurov 251444fcf4 SSL: support for compressed server certificates with OpenSSL.
The ssl_certificate_compression directive allows to send compressed
server certificates.  In OpenSSL, they are pre-compressed on startup.
To simplify configuration, the SSL_OP_NO_TX_CERTIFICATE_COMPRESSION
option is automatically cleared if certificates were pre-compressed.

SSL_CTX_compress_certs() may return an error in legitimate cases,
e.g., when none of compression algorithms is available or if the
resulting compressed size is larger than the original one, thus it
is silently ignored.

Certificate compression is supported in Chrome with brotli only,
in Safari with zlib only, and in Firefox with all listed algorithms.
It is supported since Ubuntu 24.10, which has OpenSSL with enabled
zlib and zstd support.

The actual list of algorithms supported in OpenSSL depends on how
the library was configured; it can be brotli, zlib, zstd as listed
in RFC 8879.
2025-08-03 19:15:16 +04:00
Sergey Kandaurov ed99269eed SSL: disabled certificate compression by default with OpenSSL.
Certificate compression is supported since OpenSSL 3.2, it is enabled
automatically as negotiated in a TLSv1.3 handshake.

Using certificate compression and decompression in runtime may be
suboptimal in terms of CPU and memory consumption in certain typical
scenarios, hence it is disabled by default on both server and client
sides.  It can be enabled with ssl_conf_command and similar directives
in upstream as appropriate, for example:

    ssl_conf_command Options RxCertificateCompression;
    ssl_conf_command Options TxCertificateCompression;

Compressing server certificates requires additional support, this is
addressed separately.
2025-08-03 19:15:16 +04:00
Sergey Kandaurov f4005126d7 Updated ngx_http_process_multi_header_lines() comments.
Missed in fcf4331a0.
2025-08-03 10:07:07 +04:00
Sergey Kandaurov 372659114e HTTP/3: improved invalid ":authority" error message. 2025-08-03 10:07:07 +04:00
Sergey Kandaurov 4d857aaf43 Made ngx_http_process_request_header() static again.
The function contains mostly HTTP/1.x specific request processing,
which has no use in other protocols.  After the previous change in
HTTP/2, it can now be hidden.

This is an API change.
2025-08-03 10:07:07 +04:00
Sergey Kandaurov ede5623b15 HTTP/2: fixed handling of the ":authority" header.
Previously, it misused the Host header processing resulting in
400 (Bad Request) errors for a valid request that contains both
":authority" and Host headers with the same value, treating it
after 37984f0be as if client sent more than one Host header.
Such an overly strict handling violates RFC 9113.

The fix is to process ":authority" as a distinct header, similarly
to processing an authority component in the HTTP/1.x request line.
This allows to disambiguate and compare Host and ":authority"
values after all headers were processed.

With this change, the ngx_http_process_request_header() function
can no longer be used here, certain parts were inlined similar to
the HTTP/3 module.

To provide compatibility for misconfigurations that use $http_host
to return the value of the ":authority" header, the Host header,
if missing, is now reconstructed from ":authority".
2025-08-03 10:07:07 +04:00
Sergey Kandaurov a238bb3d22 HTTP/2: factored out constructing the Host header.
No functional changes.
2025-08-03 10:07:07 +04:00
Roman Arutyunyan 50932c3c6c HTTP/2: fixed flushing early hints over SSL.
Previously, when using HTTP/2 over SSL, an early hints HEADERS frame was
queued in SSL buffer, and might not be immediately flushed.  This resulted
in a delay of early hints delivery until the main response was sent.

The fix is to set the flush flag for the early hints HEADERS frame buffer.
2025-07-28 21:06:48 +04:00
Roman Arutyunyan 4da7711082 HTTP/3: fixed handling of :authority and Host with port.
RFC 9114, Section 4.3.1. specifies a restriction for :authority and Host
coexistence in an HTTP/3 request:

: If both fields are present, they MUST contain the same value.

Previously, this restriction was correctly enforced only for portless
values.  When Host contained a port, the request failed as if :authority
and Host were different, regardless of :authority presence.

This happens because the value of r->headers_in.server used for :authority
has port stripped.  The fix is to use r->host_start / r->host_end instead.
2025-07-24 20:15:55 +04:00
Sergey Kandaurov 3739fe94d1 HTTP/3: fixed potential type overflow in string literal parser.
This might happen for Huffman encoded string literals as the result
of length expansion.  Notably, the maximum length of string literals
is already limited with the "large_client_header_buffers" directive,
so this was only possible with nonsensically large configured limits.
2025-07-23 17:24:43 +04:00
Sergey Kandaurov c52c5698cd Events: compatibility with NetBSD 10.0 in kqueue.
The kevent udata field was changed from intptr_t to "void *",
similar to other BSDs and Darwin.

The NGX_KQUEUE_UDATA_T macro is adjusted to reflect that change,
fixing -Werror=int-conversion errors.
2025-07-11 16:25:51 +04:00
Sergey Kandaurov 3f5f8a7f51 Configure: set NGX_KQUEUE_UDATA_T at compile time.
The NGX_KQUEUE_UDATA_T macro is used to compensate the incompatible
kqueue() API in NetBSD, it doesn't really belong to feature tests.

The change limits the macro visibility to the kqueue event module.
Moving from autotests also simplifies testing a particular NetBSD
version as seen in a subsequent change.
2025-07-11 16:25:51 +04:00
Sergey Kandaurov 0daaba5c54 Events: fixed -Wzero-as-null-pointer-constant warnings in kqueue.
The kevent udata field is special in that we maintain compatibility
with NetBSD versions that predate using the "void *" type.

The fix is to cast to intermediate uintptr_t that is casted back to
"void *" where appropriate.
2025-07-11 16:25:51 +04:00
Sergey Kandaurov a5ca38f303 SSL: fixed testing OPENSSL_VERSION_NUMBER for OpenSSL 3.0+.
Prior to OpenSSL 3.0, OPENSSL_VERSION_NUMBER used the following format:

MNNFFPPS: major minor fix patch status

Where the status nibble (S) has 0+ for development and f for release.

The format was changed in OpenSSL 3.0.0, where it is always zero:

MNN00PP0: major minor patch
2025-07-10 19:00:45 +04:00
Sergey Kandaurov a5d60c30d3 SSL: SSL_group_to_name() compatibility macro.
No functional changes.
2025-07-10 19:00:45 +04:00
Sergey Kandaurov 0bb7489cb2 QUIC: adjusted OpenSSL 3.5 QUIC API feature test.
A bug with the "quic_transport_parameters" extension and SNI described
in cedb855d7 is now fixed in the OpenSSL 3.5.1 release, as requested
in https://github.com/openssl/openssl/pull/27706.
2025-07-03 22:50:25 +04:00
Sergey Kandaurov d1843e1d9b Win32: fixed PCRE license for nginx/Windows zip. 2025-06-25 14:19:13 +04:00
Sergey Kandaurov 279fe352cb Version bump. 2025-06-25 14:19:13 +04:00
Sergey Kandaurov 235f409907 nginx-1.29.0-RELEASE 2025-06-24 21:22:41 +04:00
Sergey Kandaurov 1263d6bec3 Updated OpenSSL and PCRE used for win32 builds. 2025-06-24 21:22:41 +04:00
Sergey Kandaurov b997be14f5 Win32: skip OpenSSL dependency generation to conserve time.
Disabling the build dependency feature is safe assuming that
nginx/Windows release zip is always built from a clean tree.
This allows to speed up total build time by around 40%.

As it may not be suitable in general, the option resides here
and not in configure.
2025-06-24 21:22:41 +04:00
Sergey Kandaurov cedb855d75 QUIC: disabled OpenSSL 3.5 QUIC API support by default.
In OpenSSL 3.5.0, the "quic_transport_parameters" extension set
internally by the QUIC API is cleared on the SSL context switch,
which disables sending QUIC transport parameters if switching to
a different server block on SNI.  See the initial report in [1].

This is fixed post OpenSSL 3.5.0 [2].  The fix is anticipated in
OpenSSL 3.5.1, which has not been released yet.  When building
with OpenSSL 3.5, OpenSSL compat layer is now used by default.
The OpenSSL 3.5 QUIC API support can be switched back using
--with-cc-opt='-DNGX_QUIC_OPENSSL_API=1'.

[1] https://github.com/nginx/nginx/issues/711
[2] https://github.com/openssl/openssl/commit/45bd3c3798
2025-06-23 22:35:09 +04:00
Sergey Kandaurov cdf7a9c6cb Upstream: fixed reinit request with gRPC and Early Hints.
The gRPC module context has connection specific state, which can be lost
after request reinitialization when it comes to processing early hints.

The fix is to do only a portion of u->reinit_request() implementation
required after processing early hints, now inlined in modules.

Now NGX_HTTP_UPSTREAM_EARLY_HINTS is returned from u->process_header()
for early hints.  When reading a cached response, this code is mapped
to NGX_HTTP_UPSTREAM_INVALID_HEADER to indicate invalid header format.
2025-06-23 20:12:21 +04:00