summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-10-25HTTP/3: implement keepalive for hq.Roman Arutyunyan1-17/+30
Previously, keepalive timer was deleted in ngx_http_v3_wait_request_handler() and set in request cleanup handler. This worked for HTTP/3 connections, but not for hq connections. Now keepalive timer is deleted in ngx_http_v3_init_request_stream() and set in connection cleanup handler, which works both for HTTP/3 and hq.
2022-11-30QUIC: application init() callback.Roman Arutyunyan6-28/+64
It's called after handshake completion or prior to the first early data stream creation. The callback should initialize application-level data before creating streams. HTTP/3 callback implementation sets keepalive timer and sends SETTINGS. Also, this allows to limit max handshake time in ngx_http_v3_init_stream().
2022-08-22HTTP/3: renamed functions.Roman Arutyunyan3-6/+6
ngx_http_v3_init() is renamed ngx_http_v3_init_stream(). ngx_http_v3_reset_connection() is renamed to ngx_http_v3_reset_stream().
2022-11-30QUIC: removed cancelable flag from QUIC and HTTP/3 events.Roman Arutyunyan2-5/+0
All these events are created in context of a client connection and are deleted when the connection is closed. Setting ev->cancelable could trigger premature connection closure and a socket leak alert.
2022-10-19QUIC: idle mode for main connection.Roman Arutyunyan5-4/+57
Now main QUIC connection for HTTP/3 always has c->idle flag set. This allows the connection to receive worker shutdown notification. It is passed to application level via a new conf->shutdown() callback. The HTTP/3 shutdown callback sends GOAWAY to client and gracefully shuts down the QUIC connection.
2022-10-19HTTP/3: unified hq code with regular HTTP/3 code.Roman Arutyunyan4-100/+62
The change removes hq-specific request handler. Now hq requests are handled by the HTTP/3 request handler.
2022-09-07QUIC: do not send MAX_STREAMS in shutdown state.Roman Arutyunyan1-8/+9
No more streams are expected from client.
2022-08-22QUIC: defer stream removal until all its data is acked.Roman Arutyunyan3-23/+64
Previously, stream was kept alive until all its data is sent. This resulted in disabling retransmission of final part of stream when QUIC connection was closed right after closing stream connection.
2022-11-29QUIC: reusable mode for main connection.Roman Arutyunyan4-54/+110
The connection is automatically switched to this mode by transport layer when there are no non-cancelable streams. Currently, cancelable streams are HTTP/3 encoder/decoder/control streams.
2022-09-07QUIC: post close event for connection close.Roman Arutyunyan2-23/+26
Previously, close event was used only for close timeout, while read event was used for posting connection close.
2022-08-22QUIC: made ngx_quic_finalize_connecion() more graceful.Roman Arutyunyan1-18/+14
Previously, ngx_quic_finalize_connection() closed the connection with NGX_ERROR code, which resulted in immediate connection closure. Now the code is NGX_OK, which provides a more graceful shutdown with a timeout.
2022-09-07QUIC: treat qc->error == -1 as a missing error.Roman Arutyunyan1-3/+3
Previously, zero was used for this purpose. However, NGX_QUIC_ERR_NO_ERROR is zero too. As a result, NGX_QUIC_ERR_NO_ERROR was changed to NGX_QUIC_ERR_INTERNAL_ERROR when closing a QUIC connection.
2022-11-25QUIC: fixed computation of nonce with packet numbers beyond 2^32.Sergey Kandaurov1-4/+8
Prodded by Yu Zhu.
2022-11-25HTTP/3: fixed build without NGX_PCRE (broken by 0f5fc7a320db).Jiuzhou Cui1-0/+2
2022-11-23QUIC: fixed triggering stream read event (ticket #2409).Roman Arutyunyan1-1/+1
If a client packet carrying a stream data frame is not acked due to packet loss, the stream data is retransmitted later by client. It's also possible that the retransmitted range is bigger than before due to more stream data being available by then. If the original data was read out by the application, there would be no read event triggered by the retransmitted frame, even though it contains new data.
2022-11-22QUIC: fixed C4334 MSVC warning about 32 to 64 bits conversion.Sergey Kandaurov1-1/+1
2022-11-22QUIC: plug MSVC warning about potentially uninitialized variable.Sergey Kandaurov1-0/+4
2022-11-22Added shutdown macros for win32 required for QUIC.Sergey Kandaurov1-0/+2
2022-11-22QUIC: fixed C4389 MSVC warning about signed/unsigned mismatch.Sergey Kandaurov1-1/+2
2022-11-22QUIC: avoid using C99 designated initializers.Sergey Kandaurov2-24/+23
They are not supported by MSVC till 2012. SSL_QUIC_METHOD initialization is moved to run-time to preserve portability among SSL library implementations, which allows to reduce its visibility. Note using of a static storage to keep SSL_set_quic_method() reference valid.
2022-11-22QUIC: moved variable declaration to fix build with MSVC 2010.Sergey Kandaurov1-36/+32
Previously, ngx_quic_hkdf_t variables used declaration with assignment in the middle of a function, which is not supported by MSVC 2010. Fixing this also required to rewrite the ngx_quic_hkdf_set macro and to switch to an explicit array size.
2022-11-22QUIC: fixed C4706 warnings with MSVC 2010.Sergey Kandaurov1-16/+44
The fix is to avoid assignments within conditional expression.
2022-11-22HTTP/3: fixed server_name regex captures (ticket #2407).Sergey Kandaurov1-0/+1
Previously, HTTP/3 stream connection didn't inherit the servername regex from the main QUIC connection saved when processing SNI and using regular expressions in server names. As a result, it didn't execute to set regex captures when choosing the virtual server while parsing HTTP/3 headers.
2022-11-01Set default listen socket type in http.Roman Arutyunyan1-0/+1
The type field was added in 7999d3fbb765 at early stages of QUIC implementation and was not initialized for default listen. Missing initialization resulted in default listen socket creation error.
2022-10-20Merged with the default branch.Sergey Kandaurov13-147/+785
2022-10-20QUIC: removed compatibility with older BoringSSL API.Sergey Kandaurov1-8/+4
SSL_CIPHER_get_protocol_id() appeared in BoringSSL somewhere between BORINGSSL_API_VERSION 12 and 13 for compatibility with OpenSSL 1.1.1. It was adopted without a proper macro test, which remained unnoticed. This justifies that such old BoringSSL API isn't widely used and its support can be dropped. While here, removed SSL_set_quic_use_legacy_codepoint() that became useless after the default was flipped in BoringSSL over a year ago.
2022-10-20QUIC: support for setting QUIC methods with LibreSSL.Sergey Kandaurov1-9/+9
Setting QUIC methods is converted to use C99 designated initializers for simplicity, as LibreSSL 3.6.0 has different SSL_QUIC_METHOD layout. Additionally, only set_read_secret/set_write_secret callbacks are set. Although they are preferred in LibreSSL over set_encryption_secrets, better be on a safe side as LibreSSL has unexpectedly incompatible set_encryption_secrets calling convention expressed in passing read and write secrets split in separate calls, unlike this is documented in old BoringSSL sources. To avoid introducing further changes for the old API, it is simply disabled.
2022-10-20QUIC: using SSL_set_quic_early_data_enabled() only with QuicTLS.Sergey Kandaurov1-1/+1
This function is present in QuicTLS only. After SSL_READ_EARLY_DATA_SUCCESS became visible in LibreSSL together with experimental QUIC API, this required to revise the conditional compilation test to use more narrow macros.
2022-10-20QUIC: using native TLSv1.3 cipher suite constants.Sergey Kandaurov1-8/+11
After BoringSSL aligned[1] with OpenSSL on TLS1_3_CK_* macros, and LibreSSL uses OpenSSL naming, our own variants can be dropped now. Compatibility is preserved with libraries that lack these macros. Additionally, transition to SSL_CIPHER_get_id() fixes build error with LibreSSL that doesn't implement SSL_CIPHER_get_protocol_id(). [1] https://boringssl.googlesource.com/boringssl/+/dfddbc4ded
2022-10-19Mp4: disabled duplicate atoms.Roman Arutyunyan1-0/+147
Most atoms should not appear more than once in a container. Previously, this was not enforced by the module, which could result in worker process crash, memory corruption and disclosure.
2022-10-17SSL: improved validation of ssl_session_cache and ssl_ocsp_cache.Sergey Kandaurov3-4/+4
Now it properly detects invalid shared zone configuration with omitted size. Previously it used to read outside of the buffer boundary. Found with AddressSanitizer.
2022-10-13SSL: removed cast not needed after 5ffd76a9ccf3.Sergey Kandaurov1-1/+1
2022-10-12SSL: workaround for session timeout handling with TLSv1.3.Maxim Dounin2-0/+48
OpenSSL with TLSv1.3 updates the session creation time on session resumption and keeps the session timeout unmodified, making it possible to maintain the session forever, bypassing client certificate expiration and revocation. To make sure session timeouts are actually used, we now update the session creation time and reduce the session timeout accordingly. BoringSSL with TLSv1.3 ignores configured session timeouts and uses a hardcoded timeout instead, 7 days. So we update session timeout to the configured value as soon as a session is created.
2022-10-12SSL: optimized rotation of session ticket keys.Maxim Dounin2-19/+47
Instead of syncing keys with shared memory on each ticket operation, the code now does this only when the worker is going to change expiration of the current key, or going to switch to a new key: that is, usually at most once per second. To do so without races, the code maintains 3 keys: current, previous, and next. If a worker will switch to the next key earlier, other workers will still be able to decrypt new tickets, since they will be encrypted with the next key.
2022-10-12SSL: automatic rotation of session ticket keys.Maxim Dounin2-30/+160
As long as ssl_session_cache in shared memory is configured, session ticket keys are now automatically generated in shared memory, and rotated periodically. This can be beneficial from forward secrecy point of view, and also avoids increased CPU usage after configuration reloads. This also helps BoringSSL to properly resume sessions in configurations with multiple worker processes and no ssl_session_ticket_key directives, as BoringSSL tries to automatically rotate session ticket keys and does this independently in different worker processes, thus breaking session resumption between worker processes.
2022-10-12SSL: shorter debug messages about session tickets.Maxim Dounin1-3/+3
2022-10-12SSL: renamed session ticket key functions and data index.Maxim Dounin2-16/+13
Previously used names are way too long, renamed to simplify writing code.
2022-10-12SSL: renamed session ticket key type.Maxim Dounin2-21/+21
The ngx_ssl_session_ticket_key_t is way too long, renamed to ngx_ssl_ticket_key_t to simplify writing code.
2022-10-12SSL: style.Maxim Dounin1-0/+2
Runtime OCSP functions separated from configuration ones.
2022-10-12SSL: explicit clearing of expired sessions.Maxim Dounin1-0/+6
This reduces lifetime of session keying material in server's memory, and therefore can be beneficial from forward secrecy point of view.
2022-10-12SSL: single allocation in session cache on 32-bit platforms.Maxim Dounin2-48/+25
Given the present typical SSL session sizes, on 32-bit platforms it is now beneficial to store all data in a single allocation, since rbtree node + session id + ASN1 representation of a session takes 256 bytes of shared memory (36 + 32 + 150 = about 218 bytes plus SNI server name). Storing all data in a single allocation is beneficial for SNI names up to about 40 characters long and makes it possible to store about 4000 sessions in one megabyte (instead of about 3000 sessions now). This also slightly simplifies the code.
2022-10-12SSL: explicit session id length checking.Maxim Dounin1-2/+8
Session ids are not expected to be longer than 32 bytes, but this is theoretically possible with TLSv1.3, where session ids are essentially arbitrary and sent as session tickets. Since on 64-bit platforms we use fixed 32-byte buffer for session ids, added an explicit length check to make sure the buffer is large enough.
2022-10-12SSL: updated comment about session sizes.Maxim Dounin1-6/+6
Previous numbers are somewhat outdated, typical ASN1 representations of sessions are slightly bigger now.
2022-10-12SSL: reduced logging of session cache failures (ticket #621).Maxim Dounin2-2/+8
Session cache allocations might fail as long as the new session is different in size from the one least recently used (and freed when the first allocation fails). In particular, it might not be possible to allocate space for sessions with client certificates, since they are noticeably bigger than normal sessions. To ensure such allocation failures won't clutter logs, logging level changed to "warn", and logging is now limited to at most one warning per second.
2022-10-12SSL: disabled saving tickets to session cache.Maxim Dounin1-0/+17
OpenSSL tries to save TLSv1.3 sessions into session cache even when using tickets for stateless session resumption, "because some applications just want to know about the creation of a session". To avoid trashing session cache with useless data, we do not save such sessions now.
2022-09-30QUIC: "info" logging level on insufficient client connection ids.Sergey Kandaurov1-1/+1
Apparently, this error is reported on NAT rebinding if client didn't previously send NEW_CONNECTION_ID to supply additional connection ids.
2022-09-27Added type cast to ngx_proxy_protocol_parse_uint16().Roman Arutyunyan1-1/+3
The cast is added to make ngx_proxy_protocol_parse_uint16() similar to ngx_proxy_protocol_parse_uint32().
2022-10-12PROXY protocol v2 TLV variables.Roman Arutyunyan4-2/+265
The variables have prefix $proxy_protocol_tlv_ and are accessible by name and by type. Examples are: $proxy_protocol_tlv_0x01, $proxy_protocol_tlv_alpn.
2022-10-10Log only the first line of user input on PROXY protocol v1 error.Roman Arutyunyan1-1/+7
Previously, all received user input was logged. If a multi-line text was received from client and logged, it could reduce log readability and also make it harder to parse nginx log by scripts. The change brings to PROXY protocol the same behavior that exists for HTTP request line in ngx_http_log_error_handler().
2022-09-08SSL: silenced GCC warnings when building with BoringSSL.Sergey Kandaurov1-1/+1
BoringSSL uses macro stub for SSL_CTX_set_ecdh_auto that expands to 1, which triggers -Wunused-value "statement with no effect" warnings.