summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-04-18SSL: compatibility with OpenSSL master branch.Sergey Kandaurov1-1/+1
The SSL_CTRL_SET_CURVES_LIST macro is removed in the OpenSSL master branch. SSL_CTX_set1_curves_list is preserved as compatibility with previous versions.
2017-04-18SSL: disabled renegotiation detection in client mode.Sergey Kandaurov2-1/+8
CVE-2009-3555 is no longer relevant and mitigated by the renegotiation info extension (secure renegotiation). On the other hand, unexpected renegotiation still introduces potential security risks, and hence we do not allow renegotiation on the server side, as we never request renegotiation. On the client side the situation is different though. There are backends which explicitly request renegotiation, and disabled renegotiation introduces interoperability problems. This change allows renegotiation on the client side, and fixes interoperability problems as observed with such backends (ticket #872). Additionally, with TLSv1.3 the SSL_CB_HANDSHAKE_START flag is currently set by OpenSSL when receiving a NewSessionTicket message, and was detected by nginx as a renegotiation attempt. This looks like a bug in OpenSSL, though this change also allows better interoperability till the problem is fixed.
2017-04-18SSL: added support for TLSv1.3 in ssl_protocols directive.Sergey Kandaurov2-0/+7
Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
2017-03-28Core: set nginx_shared_zone name via ngx_str_set().Ruslan Ermilov1-2/+1
2017-03-17Fixed a comment.Ruslan Ermilov1-1/+1
2017-03-07Cancelable timers are now preserved if there are other timers.Maxim Dounin2-27/+15
There is no need to cancel timers early if there are other timers blocking shutdown anyway. Preserving such timers allows nginx to continue some periodic work till the shutdown is actually possible. With the new approach, timers with ev->cancelable are simply ignored when checking if there are any timers left during shutdown.
2017-03-06Added missing "static" specifiers found by gcc -Wtraditional.Ruslan Ermilov2-2/+2
2017-03-02Added missing static specifiers.Eran Kornblau9-26/+26
2017-02-06SSL: clear error queue after OPENSSL_init_ssl().Sergey Kandaurov1-1/+11
The function may leave error in the error queue while returning success, e.g., when taking a DSO reference to itself as of OpenSSL 1.1.0d: https://git.openssl.org/?p=openssl.git;a=commit;h=4af9f7f Notably, this fixes alert seen with statically linked OpenSSL on some platforms. While here, check OPENSSL_init_ssl() return value.
2017-01-20Upstream: fixed cache corruption and socket leaks with aio_write.Maxim Dounin1-0/+13
The ngx_event_pipe() function wasn't called on write events with wev->delayed set. As a result, threaded writing results weren't properly collected in ngx_event_pipe_write_to_downstream() when a write event was triggered for a completed write. Further, this wasn't detected, as p->aio was reset by a thread completion handler, and results were later collected in ngx_event_pipe_read_upstream() instead of scheduling a new write of additional data. If this happened on the last reading from an upstream, last part of the response was never written to the cache file. Similar problems might also happen in case of timeouts when writing to client, as this also results in ngx_event_pipe() not being called on write events. In this scenario socket leaks were observed. Fix is to check if p->writing is set in ngx_event_pipe_read_upstream(), and therefore collect results of previous write operations in case of read events as well, similar to how we do so in ngx_event_pipe_write_downstream(). This is enough to fix the wev->delayed case. Additionally, we now call ngx_event_pipe() from ngx_http_upstream_process_request() if there are uncollected write operations (p->writing and !p->aio). This also fixes the wev->timedout case.
2016-12-23SSL: support AES256 encryption of tickets.Maxim Dounin2-16/+47
This implies ticket key size of 80 bytes instead of previously used 48, as both HMAC and AES keys are 32 bytes now. When an old 48-byte ticket key is provided, we fall back to using backward-compatible AES128 encryption. OpenSSL switched to using AES256 in 1.1.0, and we are providing equivalent security. While here, order of HMAC and AES keys was reverted to make the implementation compatible with keys used by OpenSSL with SSL_CTX_set_tlsext_ticket_keys(). Prodded by Christian Klinger.
2016-12-15SSL: backed out changeset e7cb5deb951d, reimplemented properly.Maxim Dounin2-6/+6
Changeset e7cb5deb951d breaks build on CentOS 5 with "dereferencing type-punned pointer will break strict-aliasing rules" warning. It is backed out. Instead, to keep builds with BoringSSL happy, type of the "value" variable changed to "char *", and an explicit cast added before calling ngx_parse_http_time().
2016-12-13SSL: fix call to BIO_get_mem_data().Piotr Sikora2-2/+2
Fixes build with BoringSSL. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-12-05SSL: $ssl_curves (ticket #1088).Maxim Dounin2-0/+70
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.
2016-12-05SSL: $ssl_ciphers (ticket #870).Maxim Dounin2-0/+86
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.
2016-12-05SSL: $ssl_client_v_start, $ssl_client_v_end, $ssl_client_v_remain.Maxim Dounin2-0/+184
2016-12-05SSL: $ssl_client_verify extended with a failure reason.Maxim Dounin1-8/+18
Now in case of a verification failure $ssl_client_verify contains "FAILED:<reason>", similar to Apache's SSL_CLIENT_VERIFY, e.g., "FAILED:certificate has expired". Detailed description of possible errors can be found in the verify(1) manual page as provided by OpenSSL.
2016-12-05OCSP stapling: improved error logging context.Maxim Dounin1-1/+19
It now logs the IP address of the responder used (if it's already known), as well as the certificate name.
2016-12-05OCSP stapling: added certificate name to warnings.Maxim Dounin3-5/+36
2016-12-05OCSP stapling: added http response status logging.Maxim Dounin1-6/+9
2016-12-05OCSP stapling: style.Maxim Dounin1-10/+12
2016-11-21Events: improved error event handling for UDP sockets.Dmitry Volyntsev4-30/+19
Normally, the epoll module calls the read and write handlers depending on whether EPOLLIN and EPOLLOUT are reported by epoll_wait(). No error processing is done in the module, the handlers are expected to get an error when doing I/O. If an error event is reported without EPOLLIN and EPOLLOUT, the module set both EPOLLIN and EPOLLOUT to ensure the error event is handled at least in one active handler. This works well unless the error is delivered along with only one of EPOLLIN or EPOLLOUT, and the corresponding handler does not do any I/O. For example, it happened when getting EPOLLERR|EPOLLOUT from epoll_wait() upon receiving "ICMP port unreachable" while proxying UDP. As the write handler had nothing to send it was not able to detect and log an error, and did not switch to the next upstream. The fix is to unconditionally set EPOLLIN and EPOLLOUT in case of an error event. In the aforementioned case, this causes the read handler to be called which does recv() and detects an error. In addition to the epoll module, analogous changes were made in devpoll/eventport/poll.
2016-10-21SSL: RFC2253 compliant $ssl_client_s_dn and $ssl_client_i_dn.Dmitry Volyntsev2-1/+109
Originally, the variables kept a result of X509_NAME_oneline(), which is, according to the official documentation, a legacy function. It produces a non standard output form and has various quirks and inconsistencies. The RFC2253 compliant behavior is introduced for these variables. The original variables are available through $ssl_client_s_dn_legacy and $ssl_client_i_dn_legacy.
2016-10-18SSL: overcame possible buffer over-read in ngx_ssl_error().Valentin Bartenev1-1/+3
It appeared that ERR_error_string_n() cannot handle zero buffer size well enough and causes over-read. The problem has also been fixed in OpenSSL: https://git.openssl.org/?p=openssl.git;h=e5c1361580d8de79682958b04a5f0d262e680f8b
2016-10-10Modules compatibility: compatibility with NGX_HTTP_SSL.Maxim Dounin2-8/+5
With this change it is now possible to load modules compiled without the "--with-http_ssl_module" configure option into nginx binary compiled with it, and vice versa (if a module doesn't use ssl-specific functions), assuming both use the "--with-compat" option.
2016-10-10Modules compatibility: compatibility with NGX_HAVE_FILE_AIO.Maxim Dounin1-1/+1
With this change it is now possible to load modules compiled without the "--with-file-aio" configure option into nginx binary compiled with it, and vice versa, assuming both use the "--with-compat" option.
2016-10-10Modules compatibility: compatibility with NGX_THREADS.Maxim Dounin1-1/+1
With this change it is now possible to load modules compiled without the "--with-threads" configure option into nginx binary compiled with it, and vice versa (if a module does not use thread-specific functions), assuming both use the "--with-compat" option.
2016-10-04SSL: use X509_check_host() with LibreSSL.Maxim Dounin1-3/+3
Explicit checks for OPENSSL_VERSION_NUMBER replaced with checks for X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT, thus allowing X509_check_host() to be used with other libraries. In particular, X509_check_host() was introduced in LibreSSL 2.5.0.
2016-09-29Introduced the NGX_COMPAT macro.Ruslan Ermilov1-0/+3
When enabled, some structures are padded to be size compatible with their NGINX Plus versions.
2016-09-29Modules compatibility: peer.notify.Maxim Dounin1-0/+3
This callback can be used to notify balancer about various events. For now, it is only used in nginx-plus.
2016-09-20Fixed log levels of configuration parsing errors.Valentin Bartenev1-2/+2
All the errors that prevent loading configuration must be printed on the "emerg" log level. Previously, nginx might silently fail to load configuration in some cases as the default log level is "error".
2016-09-20Removed influence of some options on structures.Ruslan Ermilov1-2/+0
2016-09-15Stream: filters.Roman Arutyunyan4-0/+5
2016-09-12OCSP stapling: fixed using wrong responder with multiple certs.Maxim Dounin1-0/+3
2016-09-12SSL: improved session ticket callback error handling.Sergey Kandaurov1-3/+32
Prodded by Guido Vranken.
2016-09-12SSL: factored out digest and cipher in session ticket callback.Sergey Kandaurov1-14/+14
No functional changes.
2016-09-01Event pipe: do not set file's thread_handler if not needed.Maxim Dounin1-4/+6
This fixes a problem with aio threads and sendfile with aio_write switched off, as observed with range requests after fc72784b1f52 (1.9.13). Potential problems with sendfile in threads were previously described in 9fd738b85fad, and this seems to be one of them. The problem occurred as file's thread_handler was set to NULL by event pipe code after a sendfile thread task was scheduled. As a result, no sendfile completion code was executed, and the same buffer was additionally sent using non-threaded sendfile. Fix is to avoid modifying file's thread_handler if aio_write is switched off. Note that with "aio_write on" it is still possible that sendfile will use thread_handler as set by event pipe. This is believed to be safe though, as handlers used are compatible.
2016-09-01Event pipe: process data after recv_chain() errors.Maxim Dounin1-1/+1
When c->recv_chain() returns an error, it is possible that we already have some data previously read, e.g., in preread buffer. And in some cases it may be even a complete response. Changed c->recv_chain() error handling to process the data, much like it is already done if kevent reports about an error. This change, in particular, fixes processing of small responses when an upstream fails to properly close a connection with lingering and therefore the connection is reset, but the response is already fully obtained by nginx (see ticket #1037).
2016-08-22SSL: adopted session ticket handling for OpenSSL 1.1.0.Sergey Kandaurov1-1/+1
Return 1 in the SSL_CTX_set_tlsext_ticket_key_cb() callback function to indicate that a new session ticket is created, as per documentation. Until 1.1.0, OpenSSL didn't make a distinction between non-negative return values. See https://git.openssl.org/?p=openssl.git;a=commitdiff;h=5c753de for details.
2016-08-18SSL: remove no longer needed workaround for BoringSSL.Piotr Sikora1-2/+0
BoringSSL added a no-op stub for OPENSSL_config() on 2016-01-26. Requested by David Benjamin. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2016-08-22Events: fixed setting of IP_BIND_ADDRESS_NO_PORT/SO_REUSEADDR.Ruslan Ermilov1-1/+1
The IP_BIND_ADDRESS_NO_PORT option is set on upstream sockets if proxy_bind does not specify a port. The SO_REUSEADDR option is set on UDP upstream sockets if proxy_bind specifies a port. Due to checking of the wrong port, IP_BIND_ADDRESS_NO_PORT was never set, and SO_REUSEPORT was always set.
2016-08-08SSL: guarded SSL_R_NO_CIPHERS_PASSED not present in OpenSSL 1.1.0.Sergey Kandaurov1-0/+2
It was removed in OpenSSL 1.1.0 Beta 3 (pre-release 6). It was not used since OpenSSL 1.0.1n and 1.0.2b.
2016-07-15Events: support for EPOLLEXCLUSIVE.Valentin Bartenev3-3/+41
This flag appeared in Linux 4.5 and is useful for avoiding thundering herd problem. The current Linux kernel implementation walks the list of exclusive waiters, and queues an event to each epfd, until it finds the first waiter that has threads blocked on it via epoll_wait().
2016-07-15Style: sorted epoll flags.Valentin Bartenev1-3/+3
2016-07-15Events: the "accept_mutex" directive is turned off by default.Valentin Bartenev1-1/+1
Now it is believed that the accept mutex brings more harm than benefits. Especially in various benchmarks it often results in situation where only one worker grabs all connections.
2016-06-29Removed unused flag accept_context_updated from ngx_event_t.Ruslan Ermilov2-7/+2
Also, removed practically unused flag accept_context_updated from ngx_connection_t.
2016-06-20Stream: set SO_REUSEADDR for UDP upstream sockets.Roman Arutyunyan1-1/+25
The option is only set if the socket is bound to a specific port to allow several such sockets coexist at the same time. This is required, for example, when nginx acts as a transparent proxy and receives two datagrams from the same client in a short time. The feature is only implemented for Linux.
2016-06-20Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan1-13/+1
2016-06-20Set IP_BIND_ADDRESS_NO_PORT socket option for upstream sockets.Andrei Belov1-0/+26
2016-06-15SSL: ngx_ssl_ciphers() to set list of ciphers.Tim Taubert2-0/+26
This patch moves various OpenSSL-specific function calls into the OpenSSL module and introduces ngx_ssl_ciphers() to make nginx more crypto-library-agnostic.