summaryrefslogtreecommitdiffhomepage
path: root/src/event (follow)
AgeCommit message (Collapse)AuthorFilesLines
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.
2016-05-23Introduced the ngx_sockaddr_t type.Ruslan Ermilov1-9/+8
It's properly aligned and can hold any supported sockaddr.
2016-05-19SSL: removed default DH parameters.Maxim Dounin1-45/+0
Using the same DH parameters on multiple servers is believed to be subject to precomputation attacks, see http://weakdh.org/. Additionally, 1024 bits are not enough in the modern world as well. Let users provide their own DH parameters with the ssl_dhparam directive if they want to use EDH ciphers. Note that SSL_CTX_set_dh_auto() as provided by OpenSSL 1.1.0 uses fixed DH parameters from RFC 5114 and RFC 3526, and therefore subject to the same precomputation attacks. We avoid using it as well. This change also fixes compilation with OpenSSL 1.1.0-pre5 (aka Beta 2), as OpenSSL developers changed their policy after releasing Beta 1 and broke API once again by making the DH struct opaque (see ticket #860).
2016-05-19SSL: support for multiple curves (ticket #885).Maxim Dounin1-5/+48
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.
2016-05-19SSL: style.Maxim Dounin1-4/+4
2016-05-19SSL: error messages style.Maxim Dounin1-2/+2
2016-05-19SSL: support for multiple certificates (ticket #814).Maxim Dounin2-0/+25
2016-05-19SSL: support for per-certificate chains.Maxim Dounin2-2/+33
The SSL_CTX_add0_chain_cert() function as introduced in OpenSSL 1.0.2 now used instead of SSL_CTX_add_extra_chain_cert(). SSL_CTX_add_extra_chain_cert() adds extra certs for all certificates in the context, while SSL_CTX_add0_chain_cert() only to a particular certificate. There is no difference unless multiple certificates are used, though it is important when using multiple certificates. Additionally, SSL_CTX_select_current_cert() is now called before using a chain to make sure correct chain will be returned.
2016-05-19SSL: made it possible to iterate though all certificates.Maxim Dounin3-24/+66
A pointer to a previously configured certificate now stored in a certificate. This makes it possible to iterate though all certificates configured in the SSL context. This is now used to configure OCSP stapling for all certificates, and in ngx_ssl_session_id_context(). As SSL_CTX_use_certificate() frees previously loaded certificate of the same type, and we have no way to find out if it's the case, X509_free() calls are now posponed till ngx_ssl_cleanup_ctx(). Note that in OpenSSL 1.0.2+ this can be done without storing things in exdata using the SSL_CTX_set_current_cert() and SSL_CTX_get0_certificate() functions. These are not yet available in all supported versions though, so it's easier to continue to use exdata for now.
2016-05-19OCSP stapling: additional function to configure stapling on a cert.Maxim Dounin1-11/+26
2016-05-19OCSP stapling: staple now extracted via SSL_get_certificate().Maxim Dounin1-2/+8
This makes it possible to properly return OCSP staple with multiple certificates configured. Note that it only works properly in OpenSSL 1.0.1d+, 1.0.0k, 0.9.8y+. In older versions SSL_get_certificate() fails to return correct certificate when the certificate status callback is called.
2016-05-19OCSP stapling: staple now stored in certificate, not SSL context.Maxim Dounin2-13/+13
2016-05-19OCSP stapling: staple provided in arguments.Maxim Dounin1-26/+22
2016-05-18Events: close descriptors on errors in ngx_epoll_test_rdhup().Maxim Dounin1-5/+18
2016-05-18Events: changed ngx_epoll_test_rdhup() to use existing epollfd.Maxim Dounin1-12/+3
2016-05-18Fixed work with --test-build-epoll after f7849bfb6d21.Maxim Dounin1-66/+70
2016-05-16Fixed an error log message about epoll_wait() timeout.Valentin Bartenev1-2/+2
The errno value is unset in case of epoll_wait() timeout.
2016-05-13Improved EPOLLRDHUP handling.Valentin Bartenev2-1/+78
When it's known that the kernel supports EPOLLRDHUP, there is no need in additional recv() call to get EOF or error when the flag is absent in the event generated by the kernel. A special runtime test is done at startup to detect if EPOLLRDHUP is actually supported by the kernel because epoll_ctl() silently ignores unknown flags. With this knowledge it's now possible to drop the "ready" flag for partial read. Previously, the "ready" flag was kept until the recv() returned EOF or error. In particular, this change allows the lingering close heuristics (which relies on the "ready" flag state) to actually work on Linux, and not wait for more data in most cases. The "available" flag is now used in the read event with the semantics similar to the corresponding counter in kqueue.
2016-04-28Removed unused flag unexpected_eof from ngx_connection_t.Ruslan Ermilov2-4/+0
2015-12-18Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan2-0/+106
This parameter lets binding the proxy connection to a non-local address. Upstream will see the connection as coming from that address. When used with $remote_addr, upstream will accept the connection from real client address. Example: proxy_bind $remote_addr transparent;
2016-04-08Removed redundant "u" format specifier.Ruslan Ermilov1-1/+1
It is implied for "x" and "X".
2016-04-07Fixed spelling.Josh Soref1-1/+1
2016-03-31SSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.Maxim Dounin1-0/+11
SSLeay_version() and SSLeay() are no longer available if OPENSSL_API_COMPAT is set to 0x10100000L. Switched to using OpenSSL_version() instead. Additionally, we now compare version strings instead of version numbers, and this correctly works for LibreSSL as well.
2016-03-31SSL: X509 was made opaque in OpenSSL 1.1.0.Sergey Kandaurov1-0/+4
To increment reference counters we now use newly introduced X509_up_ref() function.
2016-03-31SSL: EVP_MD_CTX was made opaque in OpenSSL 1.1.0.Sergey Kandaurov1-9/+12
2016-03-31SSL: RSA_generate_key() is deprecated in OpenSSL 1.1.0.Maxim Dounin1-1/+1
OpenSSL removed support for all 40 and 56 bit ciphers.
2016-03-31SSL: initialization changes for OpenSSL 1.1.0.Maxim Dounin1-0/+12
OPENSSL_config() deprecated in OpenSSL 1.1.0. Additionally, SSL_library_init(), SSL_load_error_strings() and OpenSSL_add_all_algorithms() are no longer available if OPENSSL_API_COMPAT is set to 0x10100000L. The OPENSSL_init_ssl() function is now used instead with appropriate arguments to trigger the same behaviour. The configure test changed to use SSL_CTX_set_options(). Deinitialization now happens automatically in OPENSSL_cleanup() called via atexit(3), so we no longer call EVP_cleanup() and ENGINE_cleanup() directly.
2016-03-31SSL: get_session callback changed in OpenSSL 1.1.0.Maxim Dounin1-4/+11
2016-03-31SSL: guarded error codes not present in OpenSSL 1.1.0.Maxim Dounin1-1/+4
2016-03-31SSL: reasonable version for LibreSSL.Maxim Dounin2-3/+9
LibreSSL defines OPENSSL_VERSION_NUMBER to 0x20000000L, but uses an old API derived from OpenSSL at the time LibreSSL forked. As a result, every version check we use to test for new API elements in newer OpenSSL versions requires an explicit check for LibreSSL. To reduce clutter, redefine OPENSSL_VERSION_NUMBER to 0x1000107fL if LibreSSL is used. The same is done by FreeBSD port of LibreSSL.
2016-03-31Fixed logging.Sergey Kandaurov5-6/+6
2016-03-31Events: fixed logging.Sergey Kandaurov2-12/+19
2016-03-30Events: fixed test building with eventport on OS X.Ruslan Ermilov1-1/+1
Broken in d17f0584006f (1.9.13).
2016-03-30Style.Ruslan Ermilov4-30/+30
2016-03-28Fixed --test-build-*.Ruslan Ermilov2-3/+4
Fixes various aspects of --test-build-devpoll, --test-build-eventport, and --test-build-epoll. In particular, if --test-build-devpoll was used on Linux, then "devpoll" event method would be preferred over "epoll". Also, wrong definitions of event macros were chosen.
2016-03-21Events: fixed test building with devpoll and eventport on Linux.Sergey Kandaurov2-1/+3
Avoid POLLREMOVE and itimerspec redefinition.
2016-03-18Threads: writing via threads pools in event pipe.Maxim Dounin2-20/+88
The "aio_write" directive is introduced, which enables use of aio for writing. Currently it is meaningful only with "aio threads". Note that aio operations can be done by both event pipe and output chain, so proper mapping between r->aio and p->aio is provided when calling ngx_event_pipe() and in output filter. In collaboration with Valentin Bartenev.
2016-03-18Fixed timeouts with threaded sendfile() and subrequests.Maxim Dounin1-0/+3
If a write event happens after sendfile() but before we've got the sendfile results in the main thread, this write event will be ignored. And if no more events will happen, the connection will hang. Removing the events works in the simple cases, but not always, as in some cases events are added back by an unrelated code. E.g., the upstream module adds write event in the ngx_http_upstream_init() to track client aborts. Fix is to use wev->complete instead. It is now set to 0 before a sendfile() task is posted, and it is set to 1 once a write event happens. If on completion of the sendfile() task wev->complete is 1, we know that an event happened while we were executing sendfile(), and the socket is still ready for writing even if sendfile() did not sent all the data or returned EAGAIN.
2016-01-20Stream: UDP proxy.Roman Arutyunyan5-65/+418
2016-03-15Events: fixed error logging in devpoll.Roman Arutyunyan1-1/+1
2016-02-19SSL: avoid calling SSL_shutdown() during handshake (ticket #901).Maxim Dounin1-0/+13
This fixes "called a function you should not call" and "shutdown while in init" errors as observed with OpenSSL 1.0.2f due to changes in how OpenSSL handles SSL_shutdown() during SSL handshakes.
2016-02-19SSL: fixed SSL_shutdown() comment.Maxim Dounin1-1/+1
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin1-21/+23
2016-02-04Dynamic modules: moved module-related stuff to separate files.Maxim Dounin1-8/+1
2015-10-20Win32: timer_resolution now ignored with select.Maxim Dounin1-0/+9
As setitimer() isn't available on Windows, time wasn't updated at all if timer_resolution was used with the select event method. Fix is to ignore timer_resolution in such cases.
2015-10-19SSL: preserve default server context in connection (ticket #235).Maxim Dounin2-12/+8
This context is needed for shared sessions cache to work in configurations with multiple virtual servers sharing the same port. Unfortunately, OpenSSL does not provide an API to access the session context, thus storing it separately. In collaboration with Vladimir Homutov.