summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_request.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-03-24QUIC streams don't need filter_need_in_memory after 7f0981be07c4.Sergey Kandaurov1-1/+0
Now they inherit c->ssl always enabled from the main connection, which makes r->main_filter_need_in_memory set for them.
2020-03-23Fixed client certificate verification.Sergey Kandaurov1-0/+1
For ngx_http_process_request() part to work, this required to set both r->http_connection->ssl and c->ssl on a QUIC stream. To avoid damaging global SSL object, ngx_ssl_shutdown() is managed to ignore QUIC streams.
2020-03-23Respect QUIC max_idle_timeout.Roman Arutyunyan1-3/+1
2020-03-20Configurable transport parameters.Vladimir Homutov1-1/+4
- integer parameters can be configured using the following directives: quic_max_idle_timeout quic_max_ack_delay quic_max_packet_size quic_initial_max_data quic_initial_max_stream_data_bidi_local quic_initial_max_stream_data_bidi_remote quic_initial_max_stream_data_uni quic_initial_max_streams_bidi quic_initial_max_streams_uni quic_ack_delay_exponent quic_active_migration quic_active_connection_id_limit - only following parameters are actually sent: active_connection_id_limit initial_max_streams_uni initial_max_streams_bidi initial_max_stream_data_bidi_local initial_max_stream_data_bidi_remote initial_max_stream_data_uni (other parameters are to be added into ngx_quic_create_transport_params() function as needed, should be easy now) - draft 24 and draft 27 are now supported (at compile-time using quic_version macro)
2020-03-18HTTP/3 $request_line variable.Roman Arutyunyan1-2/+2
2020-03-18Refactored HTTP/3 parser.Roman Arutyunyan1-4/+10
2020-03-14Temporary fix for header null-termination in HTTP/3.Roman Arutyunyan1-2/+2
2020-03-13HTTP/3.Roman Arutyunyan1-52/+126
2020-03-13Stream "connection" read/write methods.Vladimir Homutov1-0/+31
2020-03-12Fix build.Sergey Kandaurov1-1/+2
2020-03-12HTTP/QUIC interface reworked.Vladimir Homutov1-87/+18
- events handling moved into src/event/ngx_event_quic.c - http invokes once ngx_quic_run() and passes stream callback (diff to original http_request.c is now minimal) - streams are stored in rbtree using ID as a key - when a new stream is registered, appropriate callback is called - ngx_quic_stream_t type represents STREAM and stored in c->qs
2020-02-28Simplified subrequest finalization.Roman Arutyunyan1-23/+11
Now it looks similar to what it was before background subrequests were introduced in 9552758a786e.
2020-03-02Fixed premature background subrequest finalization.Dmitry Volyntsev1-9/+9
When "aio" or "aio threads" is used while processing the response body of an in-memory background subrequest, the subrequest could be finalized with an aio operation still in progress. Upon aio completion either parent request is woken or the old r->write_event_handler is called again. The latter may result in request errors. In either case post_subrequest handler is never called with the full response body, which is typically expected when using in-memory subrequests. Currently in nginx background subrequests are created by the upstream module and the mirror module. The issue does not manifest itself with these subrequests because they are header-only. But it can manifest itself with third-party modules which create in-memory background subrequests.
2020-02-28Moved all QUIC code into ngx_event_quic.cVladimir Homutov1-545/+10
Introduced ngx_quic_input() and ngx_quic_output() as interface between nginx and protocol. They are the only functions that are exported. While there, added copyrights.
2020-02-28Introduced quic_version macro, uint16/uint32 routines ported.Sergey Kandaurov1-6/+6
2020-02-28Cleanup.Sergey Kandaurov1-48/+19
2020-02-26Generic function for HKDF expansion.Vladimir Homutov1-282/+69
2020-02-28QUIC header protection routines, introduced ngx_quic_tls_hp().Sergey Kandaurov1-38/+4
2020-02-28AEAD routines, introduced ngx_quic_tls_open()/ngx_quic_tls_seal().Sergey Kandaurov1-243/+27
2020-02-28Transport parameters stub, to complete handshake.Sergey Kandaurov1-1/+11
2020-02-28Introduced ngx_quic_secret_t.Sergey Kandaurov1-88/+88
2020-02-28QUIC handshake handler, draft 24 bump.Sergey Kandaurov1-3/+353
2020-02-28Fixed indentation.Sergey Kandaurov1-199/+196
2020-02-28PN-aware AEAD nonce, feeding proper CRYPTO length.Sergey Kandaurov1-1/+21
2020-02-28OpenSSL compatibility.Sergey Kandaurov1-52/+199
2020-02-28QUIC add_handshake_data callback, varint routines.Sergey Kandaurov1-39/+1
2020-02-28QUIC set_encryption_secrets callback.Sergey Kandaurov1-2/+2
2020-02-28Server Initial Keys.Sergey Kandaurov1-4/+137
2020-02-28Initial QUIC support in http.Sergey Kandaurov1-0/+495
2020-02-28HTTP UDP layer, QUIC support autotest.Sergey Kandaurov1-0/+10
2020-02-27Disabled connection reuse while in SSL handshake.Sergey Kandaurov1-2/+2
During SSL handshake, the connection could be reused in the OCSP stapling callback, if configured, which subsequently leads to a segmentation fault.
2020-02-20Disabled duplicate "Host" headers (ticket #1724).Maxim Dounin1-2/+10
Duplicate "Host" headers were allowed in nginx 0.7.0 (revision b9de93d804ea) as a workaround for some broken Motorola phones which used to generate requests with two "Host" headers[1]. It is believed that this workaround is no longer relevant. [1] http://mailman.nginx.org/pipermail/nginx-ru/2008-May/017845.html
2020-02-20Removed "Transfer-Encoding: identity" support.Maxim Dounin1-4/+1
The "identity" transfer coding has been removed in RFC 7230. It is believed that it is not used in real life, and at the same time it provides a potential attack vector.
2020-02-20Disabled multiple Transfer-Encoding headers.Maxim Dounin1-1/+1
We anyway do not support more than one transfer encoding, so accepting requests with multiple Transfer-Encoding headers doesn't make sense. Further, we do not handle multiple headers, and ignore anything but the first header. Reported by Filippo Valsorda.
2019-03-05SSL: moved c->ssl->handshaked check in server name callback.Maxim Dounin1-6/+6
Server name callback is always called by OpenSSL, even if server_name extension is not present in ClientHello. As such, checking c->ssl->handshaked before the SSL_get_servername() result should help to more effectively prevent renegotiation in OpenSSL 1.1.0 - 1.1.0g, where neither SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS nor SSL_OP_NO_RENEGOTIATION is available.
2019-03-03SSL: server name callback changed to return fatal errors.Maxim Dounin1-7/+22
Notably this affects various allocation errors, and should generally improve things if an allocation error actually happens during a callback. Depending on the OpenSSL version, returning an error can result in either SSL_R_CALLBACK_FAILED or SSL_R_CLIENTHELLO_TLSEXT error from SSL_do_handshake(), so both errors were switched to the "info" level.
2019-03-03SSL: server name callback changed to return SSL_TLSEXT_ERR_OK.Maxim Dounin1-6/+6
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.
2019-02-25SSL: fixed possible segfault with dynamic certificates.Maxim Dounin1-1/+1
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.
2019-02-25SSL: passwords support for dynamic certificate loading.Maxim Dounin1-1/+2
Passwords have to be copied to the configuration pool to be used at runtime. Also, to prevent blocking on stdin (with "daemon off;") an empty password list is provided. To make things simpler, password handling was modified to allow an empty array (with 0 elements and elts set to NULL) as an equivalent of an array with 1 empty password.
2019-02-25SSL: variables support in ssl_certificate and ssl_certificate_key.Maxim Dounin1-19/+105
To evaluate variables, a request is created in the certificate callback, and then freed. To do this without side effects on the stub_status counters and connection state, an additional function was introduced, ngx_http_alloc_request(). Only works with OpenSSL 1.0.2+, since there is no SSL_CTX_set_cert_cb() in older versions.
2019-02-25Style.Maxim Dounin1-0/+1
2018-10-02SSL: fixed segfault on renegotiation (ticket #1646).Maxim Dounin1-1/+5
In e3ba4026c02d (1.15.4) nginx own renegotiation checks were disabled if SSL_OP_NO_RENEGOTIATION is available. But since SSL_OP_NO_RENEGOTIATION is only set on a connection, not in an SSL context, SSL_clear_option() removed it as long as a matching virtual server was found. This resulted in a segmentation fault similar to the one fixed in a6902a941279 (1.9.8), affecting nginx built with OpenSSL 1.1.0h or higher. To fix this, SSL_OP_NO_RENEGOTIATION is now explicitly set in ngx_http_ssl_servername() after adjusting options. Additionally, instead of c->ssl->renegotiation we now check c->ssl->handshaked, which seems to be a more correct flag to test, and will prevent the segmentation fault from happening even if SSL_OP_NO_RENEGOTIATION is not working.
2018-09-21Fixed socket leak with "return 444" in error_page (ticket #274).Maxim Dounin1-24/+26
Socket leak was observed in the following configuration: error_page 400 = /close; location = /close { return 444; } The problem is that "return 444" triggers termination of the request, and due to error_page termination thinks that it needs to use a posted request to clear stack. But at the early request processing where 400 errors are generated there are no ngx_http_run_posted_requests() calls, so the request is only terminated after an external event. Variants of the problem include "error_page 497" instead (ticket #695) and various other errors generated during early request processing (405, 414, 421, 494, 495, 496, 501, 505). The same problem can be also triggered with "return 499" and "return 408" as both codes trigger ngx_http_terminate_request(), much like "return 444". To fix this, the patch adds ngx_http_run_posted_requests() calls to ngx_http_process_request_line() and ngx_http_process_request_headers() functions, and to ngx_http_v2_run_request() and ngx_http_v2_push_stream() functions in HTTP/2. Since the ngx_http_process_request() function is now only called via other functions which call ngx_http_run_posted_requests(), the call there is no longer needed and was removed.
2018-09-10Lingering close changed to handle NGX_AGAIN.Maxim Dounin1-0/+4
The "do { c->recv() } while (c->read->ready)" form used in the ngx_http_lingering_close_handler() is not really correct, as for example with SSL c->read->ready may be still set when returning NGX_AGAIN due to SSL_ERROR_WANT_WRITE. Therefore the above might be an infinite loop. This doesn't really matter in lingering close, as we shutdown write side of the socket anyway and also disable renegotiation (and even without shutdown and with renegotiation it requires using very large certificate chain and tuning socket buffers to trigger SSL_ERROR_WANT_WRITE). But for the sake of correctness added an NGX_AGAIN check.
2018-07-16SSL: fixed SSL_clear_options() usage with OpenSSL 1.1.0+.Maxim Dounin1-1/+1
In OpenSSL 1.1.0 the SSL_CTRL_CLEAR_OPTIONS macro was removed, so conditional compilation test on it results in SSL_clear_options() and SSL_CTX_clear_options() not being used. Notably, this caused "ssl_prefer_server_ciphers off" to not work in SNI-based virtual servers if server preference was switched on in the default server. It looks like the only possible fix is to test OPENSSL_VERSION_NUMBER explicitly.
2018-07-12Allow resetting connections closed by "return 444" (ticket #905).Ruslan Ermilov1-0/+1
If reset_timedout_connection is on, TCP connections closed by "return 444" will be reset instead of a normal close.
2018-06-07Added r->schema.Ruslan Ermilov1-0/+5
For HTTP/1, it keeps scheme from the absolute form of URI. For HTTP/2, the :scheme request pseudo-header field value.
2018-06-07Removed extraneous check while processing request line.Ruslan Ermilov1-1/+1
2018-04-24SSL: detect "listen ... ssl" without certificates (ticket #178).Maxim Dounin1-12/+1
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.
2018-03-17gRPC: special handling of the TE request header.Maxim Dounin1-0/+4
According to the gRPC protocol specification, the "TE" header is used to detect incompatible proxies, and at least grpc-c server rejects requests without "TE: trailers". To preserve the logic, we have to pass "TE: trailers" to the backend if and only if the original request contains "trailers" in the "TE" header. Note that no other TE values are allowed in HTTP/2, so we have to remove anything else.