Skip to content

Commit 606656e

Browse files
committed
mod_ssl: Keep existing flags when calling SSL_set_shutdown()
Preserve existing flags (SSL_RECEIVED_SHUTDOWN or SSL_SENT_SHUTDOWN) when calling SSL_set_shutdown(). For abortive or unclean shutdowns, additionally call SSL_set_quiet_shutdown(). Submitted by: Michael Kaufmann <mail michael-kaufmann.ch> Github: closes #560 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1929580 13f79535-47bb-0310-9956-ffa450edef68
1 parent 148c6b5 commit 606656e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/ssl/ssl_engine_io.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ static void ssl_filter_io_shutdown(ssl_filter_ctx_t *filter_ctx,
10311031
SSL *ssl = filter_ctx->pssl;
10321032
const char *type = "";
10331033
SSLConnRec *sslconn = myConnConfig(c);
1034+
int quiet_shutdown;
10341035
int shutdown_type;
10351036
int loglevel = APLOG_DEBUG;
10361037
const char *logno;
@@ -1076,6 +1077,7 @@ static void ssl_filter_io_shutdown(ssl_filter_ctx_t *filter_ctx,
10761077
* to force the type of handshake via SetEnvIf directive
10771078
*/
10781079
if (abortive) {
1080+
quiet_shutdown = 1;
10791081
shutdown_type = SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN;
10801082
type = "abortive";
10811083
logno = APLOGNO(01998);
@@ -1085,14 +1087,16 @@ static void ssl_filter_io_shutdown(ssl_filter_ctx_t *filter_ctx,
10851087
case SSL_SHUTDOWN_TYPE_UNCLEAN:
10861088
/* perform no close notify handshake at all
10871089
(violates the SSL/TLS standard!) */
1090+
quiet_shutdown = 1;
10881091
shutdown_type = SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN;
10891092
type = "unclean";
10901093
logno = APLOGNO(01999);
10911094
break;
10921095
case SSL_SHUTDOWN_TYPE_ACCURATE:
10931096
/* send close notify and wait for clients close notify
10941097
(standard compliant, but usually causes connection hangs) */
1095-
shutdown_type = 0;
1098+
quiet_shutdown = 0;
1099+
shutdown_type = SSL_get_shutdown(ssl);
10961100
type = "accurate";
10971101
logno = APLOGNO(02000);
10981102
break;
@@ -1103,12 +1107,16 @@ static void ssl_filter_io_shutdown(ssl_filter_ctx_t *filter_ctx,
11031107
*/
11041108
/* send close notify, but don't wait for clients close notify
11051109
(standard compliant and safe, so it's the DEFAULT!) */
1106-
shutdown_type = SSL_RECEIVED_SHUTDOWN;
1110+
quiet_shutdown = 0;
1111+
shutdown_type = SSL_get_shutdown(ssl) | SSL_RECEIVED_SHUTDOWN;
11071112
type = "standard";
11081113
logno = APLOGNO(02001);
11091114
break;
11101115
}
11111116

1117+
if (quiet_shutdown) {
1118+
SSL_set_quiet_shutdown(ssl, 1);
1119+
}
11121120
SSL_set_shutdown(ssl, shutdown_type);
11131121
modssl_smart_shutdown(ssl);
11141122

0 commit comments

Comments
 (0)