]> git.kaiwu.me - nginx.git/commitdiff
SSL: switched to detect log level based on the last error.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 8 Mar 2023 19:21:53 +0000 (22:21 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 8 Mar 2023 19:21:53 +0000 (22:21 +0300)
In some cases there might be multiple errors in the OpenSSL error queue,
notably when a libcrypto call fails, and then the SSL layer generates
an error itself.  For example, the following errors were observed
with OpenSSL 3.0.8 with TLSv1.3 enabled:

SSL_do_handshake() failed (SSL: error:02800066:Diffie-Hellman routines::invalid public key error:0A000132:SSL routines::bad ecpoint)
SSL_do_handshake() failed (SSL: error:08000066:elliptic curve routines::invalid encoding error:0A000132:SSL routines::bad ecpoint)
SSL_do_handshake() failed (SSL: error:0800006B:elliptic curve routines::point is not on curve error:0A000132:SSL routines::bad ecpoint)

In such cases it seems to be better to determine logging level based on
the last error in the error queue (the one added by the SSL layer,
SSL_R_BAD_ECPOINT in all of the above example example errors).  To do so,
the ngx_ssl_connection_error() function was changed to use
ERR_peek_last_error().

src/event/ngx_event_openssl.c

index 5f9ff5f0f309a784dfddf32fac0a77cb1f315ec7..3e6e8e5dd1932de84325ff1d0e9f905e5164343e 100644 (file)
@@ -3389,7 +3389,7 @@ ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
 
     } else if (sslerr == SSL_ERROR_SSL) {
 
-        n = ERR_GET_REASON(ERR_peek_error());
+        n = ERR_GET_REASON(ERR_peek_last_error());
 
             /* handshake failures */
         if (n == SSL_R_BAD_CHANGE_CIPHER_SPEC                        /*  103 */