summaryrefslogtreecommitdiffhomepage
path: root/src/event/ngx_event_openssl_stapling.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-10-01SSL: moved certificate storage out of exdata.Sergey Kandaurov1-15/+53
Instead of cross-linking the objects using exdata, pointers to configured certificates are now stored in ngx_ssl_t, and OCSP staples are now accessed with rbtree in it. This allows sharing these objects between SSL contexts. Based on previous work by Mini Hawthorne.
2023-12-25SSL: reasonable version for LibreSSL adjusted.Sergey Kandaurov1-1/+1
OPENSSL_VERSION_NUMBER is now redefined to 0x1010000fL for LibreSSL 3.5.0 and above. Building with older LibreSSL versions, such as 2.8.0, may now produce warnings (see cab37803ebb3) and may require appropriate compiler options to suppress them. Notably, this allows to start using SSL_get0_verified_chain() appeared in OpenSSL 1.1.0 and LibreSSL 3.5.0, without additional macro tests. Prodded by Ilya Shipitsin.
2020-10-28Core: added format specifiers to output binary data as hex.Vladimir Homutov1-10/+2
Now "s", "V", and "v" format specifiers may be prefixed with "x" (lowercase) or "X" (uppercase) to output corresponding data in hexadecimal format. In collaboration with Maxim Dounin.
2020-07-23OCSP: fixed certificate reference leak.Sergey Kandaurov1-0/+9
2020-06-15OCSP: fixed use-after-free on error.Roman Arutyunyan1-21/+20
When validating second and further certificates, ssl callback could be called twice to report the error. After the first call client connection is terminated and its memory is released. Prior to the second call and in it released connection memory is accessed. Errors triggering this behavior: - failure to create the request - failure to start resolving OCSP responder name - failure to start connecting to the OCSP responder The fix is to rearrange the code to eliminate the second call.
2020-05-23Fixed format specifiers.Sergey Kandaurov1-2/+2
2020-05-22OCSP: certificate status cache.Roman Arutyunyan1-3/+305
When enabled, certificate status is stored in cache and is used to validate the certificate in future requests. New directive ssl_ocsp_cache is added to configure the cache.
2020-05-22SSL: client certificate validation with OCSP (ticket #1534).Roman Arutyunyan1-8/+542
OCSP validation for client certificates is enabled by the "ssl_ocsp" directive. OCSP responder can be optionally specified by "ssl_ocsp_responder". When session is reused, peer chain is not available for validation. If the verified chain contains certificates from the peer chain not available at the server, validation will fail.
2020-05-22OCSP stapling: iterate over all responder addresses.Roman Arutyunyan1-13/+54
Previously only the first responder address was used per each stapling update. Now, in case of a network or parsing error, next address is used. This also fixes the issue with unsupported responder address families (ticket #1330).
2020-05-17OCSP stapling: keep extra chain in the staple object.Roman Arutyunyan1-29/+18
2020-05-06OCSP stapling: moved response verification to a separate function.Roman Arutyunyan1-136/+154
2016-04-11SSL: removed OpenSSL 0.9.7 compatibility.Sergey Kandaurov1-4/+1
2019-04-15OCSP stapling: fixed segfault with dynamic certificate loading.Maxim Dounin1-0/+5
If OCSP stapling was enabled with dynamic certificate loading, with some OpenSSL versions (1.0.2o and older, 1.1.0h and older; fixed in 1.0.2p, 1.1.0i, 1.1.1) a segmentation fault might happen. The reason is that during an abbreviated handshake the certificate callback is not called, but the certificate status callback was called (https://github.com/openssl/openssl/issues/1662), leading to NULL being returned from SSL_get_certificate(). Fix is to explicitly check SSL_get_certificate() result.
2019-04-03OCSP stapling: open ssl_stapling_file in binary-mode.Sergey Kandaurov1-1/+1
OCSP response uses the DER format and as such needs to be opened in binary-mode. This only has any effect under Win32.
2017-07-17Parenthesized ASCII-related calculations.Valentin Bartenev1-1/+1
This also fixes potential undefined behaviour in the range and slice filter modules, caused by local overflows of signed integers in expressions.
2016-12-15SSL: backed out changeset e7cb5deb951d, reimplemented properly.Maxim Dounin1-3/+3
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 Sikora1-1/+1
Fixes build with BoringSSL. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
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 Dounin1-5/+17
2016-12-05OCSP stapling: added http response status logging.Maxim Dounin1-6/+9
2016-12-05OCSP stapling: style.Maxim Dounin1-10/+12
2016-09-12OCSP stapling: fixed using wrong responder with multiple certs.Maxim Dounin1-0/+3
2016-06-20Introduced ngx_inet_get_port() and ngx_inet_set_port() functions.Roman Arutyunyan1-13/+1
2016-05-19SSL: support for per-certificate chains.Maxim Dounin1-2/+14
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 Dounin1-10/+16
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 Dounin1-9/+10
2016-05-19OCSP stapling: staple provided in arguments.Maxim Dounin1-26/+22
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-31Fixed logging.Sergey Kandaurov1-1/+1
2015-07-14OCSP stapling: fixed segfault without nextUpdate.Maxim Dounin1-5/+10
OCSP responses may contain no nextUpdate. As per RFC 6960, this means that nextUpdate checks should be bypassed. Handle this gracefully by using NGX_MAX_TIME_T_VALUE as "valid" in such a case. The problem was introduced by 6893a1007a7c (1.9.2). Reported by Matthew Baldwin.
2015-07-07OCSP stapling: fixed ssl_stapling_file (ticket #769).Maxim Dounin1-0/+1
Broken by 6893a1007a7c (1.9.2) during introduction of strict OCSP response validity checks. As stapling file is expected to be returned unconditionally, fix is to set its validity to the maximum supported time. Reported by Faidon Liambotis.
2015-06-11OCSP stapling: avoid sending expired responses (ticket #425).Maxim Dounin1-6/+62
2015-04-01OCSP stapling: missing free calls.Filipe da Silva1-0/+2
Missing call to X509_STORE_CTX_free when X509_STORE_CTX_init fails. Missing call to OCSP_CERTID_free when OCSP_request_add0_id fails. Possible leaks in vary particular scenariis of memory shortage.
2014-07-28SSL: fix build with OPENSSL_NO_ENGINE and/or OPENSSL_NO_OCSP.Piotr Sikora1-1/+1
This is really just a prerequisite for building against BoringSSL, which doesn't provide either of those features. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-04-29OCSP stapling: missing OCSP request free call.Filipe da Silva1-0/+2
2013-12-09Resolver: implemented IPv6 name to address resolving.Ruslan Ermilov1-1/+0
2013-12-06Changed resolver API to use ngx_addr_t.Ruslan Ermilov1-22/+34
2013-08-20Backed out f1a91825730a and 7094bd12c1ff.Maxim Dounin1-1/+1
While ngx_get_full_name() might have a bit more descriptive arguments, the ngx_conf_full_name() is generally easier to use when parsing configuration and limits exposure of cycle->prefix / cycle->conf_prefix details.
2013-08-06Replaced ngx_conf_full_name() with ngx_get_full_name().Valentin Bartenev1-1/+1
The ngx_get_full_name() function takes more readable arguments list.
2013-07-11Core: extended ngx_sock_ntop() with socklen parameter.Vladimir Homutov1-1/+2
On Linux, sockaddr length is required to process unix socket addresses properly due to unnamed sockets (which don't have sun_path set at all) and abstract namespace sockets.
2013-05-31OCSP stapling: fixed incorrect debug level.Ruslan Ermilov1-1/+1
2013-05-16OCSP stapling: fix error logging of successful OCSP responses.Piotr Sikora1-3/+2
Due to a bad argument list, nginx worker would crash (SIGSEGV) while trying to log the fact that it received OCSP response with "revoked" or "unknown" certificate status. While there, fix similar (but non-crashing) error a few lines above. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2012-10-01OCSP stapling: build fixes.Maxim Dounin1-5/+5
With the "ssl_stapling_verify" commit build with old OpenSSL libraries was broken due to incorrect prototype of the ngx_ssl_stapling() function. One incorrect use of ngx_log_debug() instead of ngx_log_debug2() slipped in and broke win32 build.
2012-10-01OCSP stapling: ssl_stapling_verify directive.Maxim Dounin1-4/+9
OCSP response verification is now switched off by default to simplify configuration, and the ssl_stapling_verify allows to switch it on. Note that for stapling OCSP response verification isn't something required as it will be done by a client anyway. But doing verification on a server allows to mitigate some attack vectors, most notably stop an attacker from presenting some specially crafted data to all site clients.
2012-10-01OCSP stapling: OCSP_basic_verify() OCSP_TRUSTOTHER flag now used.Maxim Dounin1-1/+1
This is expected to simplify configuration in a common case when OCSP response is signed by a certificate already present in ssl_certificate chain. This case won't need any extra trusted certificates.
2012-10-01OCSP stapling: check Content-Type.Maxim Dounin1-0/+28
This will result in better error message in case of incorrect response from OCSP responder: ... OCSP responder sent invalid "Content-Type" header: "text/plain" while requesting certificate status, responder: ... vs. ... d2i_OCSP_RESPONSE() failed (SSL: error:0D07209B:asn1 encoding routines:ASN1_get_object:too long error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error) while requesting certificate status, responder: ...
2012-10-01OCSP stapling: loading OCSP responses.Maxim Dounin1-30/+1606
This includes the ssl_stapling_responder directive (defaults to OCSP responder set in certificate's AIA extension). OCSP response for a given certificate is requested once we get at least one connection with certificate_status extension in ClientHello, and certificate status won't be sent in the connection in question. This due to limitations in the OpenSSL API (certificate status callback is blocking). Note: SSL_CTX_use_certificate_chain_file() was reimplemented as it doesn't allow to access the certificate loaded via SSL_CTX.
2012-10-01OCSP stapling: the ngx_event_openssl_stapling.c file.Maxim Dounin1-0/+140
Missed in previous commit.