[PATCH 3 of 5] SSL: adjusted debug logging of SSL_get_error()
Maxim Dounin
mdounin at mdounin.ru
Sun Mar 15 12:08:26 UTC 2026
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1773535431 -10800
# Sun Mar 15 03:43:51 2026 +0300
# Node ID 0909ff44dc383f6869ad127c0c71eaf394af94fa
# Parent 0e0da695221f4b79ce86b415d2ca979a96c24aa4
SSL: adjusted debug logging of SSL_get_error().
Previously, debug logging of SSL_get_error() result in ngx_ssl_write()
and ngx_ssl_sendfile() was done after error code modifications to fix
obvious bugs: incorrect SSL_ERROR_ZERO_RETURN, which is not at all
defined for write operations, and missing SSL_ERROR_SYSCALL in SSL_sendfile().
This approach, however, somewhat complicates testing of new OpenSSL
versions, where error codes might be returned differently. As such,
now logging is done immediately after SSL_get_error(), before any
modifications.
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -3377,6 +3377,8 @@ ngx_ssl_write(ngx_connection_t *c, u_cha
sslerr = SSL_get_error(c->ssl->connection, n);
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
+
if (sslerr == SSL_ERROR_ZERO_RETURN) {
/*
@@ -3389,8 +3391,6 @@ ngx_ssl_write(ngx_connection_t *c, u_cha
sslerr = SSL_ERROR_SYSCALL;
}
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
-
if (sslerr == SSL_ERROR_WANT_WRITE) {
if (c->ssl->saved_read_handler) {
@@ -3655,6 +3655,8 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
sslerr = SSL_get_error(c->ssl->connection, n);
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
+
if (sslerr == SSL_ERROR_ZERO_RETURN) {
/*
@@ -3679,8 +3681,6 @@ ngx_ssl_sendfile(ngx_connection_t *c, ng
sslerr = SSL_ERROR_SYSCALL;
}
- ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
-
if (sslerr == SSL_ERROR_WANT_WRITE) {
if (c->ssl->saved_read_handler) {
More information about the nginx-devel
mailing list