Skip to content

Commit 87a7351

Browse files
committed
backport 1927037 from trunk
remove antiquated 'SSLEngine optional' TLS upgrade Reviewed By: rpluem, jorton, covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1927045 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8830432 commit 87a7351

4 files changed

Lines changed: 7 additions & 92 deletions

File tree

modules/ssl/ssl_engine_config.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,13 @@ const char *ssl_cmd_SSLEngine(cmd_parms *cmd, void *dcfg, const char *arg)
741741
return NULL;
742742
}
743743
else if (!strcasecmp(arg, "Optional")) {
744-
sc->enabled = SSL_ENABLED_OPTIONAL;
744+
sc->enabled = SSL_ENABLED_FALSE;
745+
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, cmd->server, APLOGNO(10510)
746+
"'SSLEngine optional' is no longer supported");
745747
return NULL;
746748
}
747749

748-
return "Argument must be On, Off, or Optional";
750+
return "Argument must be On or Off";
749751
}
750752

751753
const char *ssl_cmd_SSLFIPS(cmd_parms *cmd, void *dcfg, int flag)

modules/ssl/ssl_engine_init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ apr_status_t ssl_init_Module(apr_pool_t *p, apr_pool_t *plog,
427427
&ssl_module);
428428

429429
sc = mySrvConfig(s);
430-
if (sc->enabled == SSL_ENABLED_TRUE || sc->enabled == SSL_ENABLED_OPTIONAL) {
430+
if (sc->enabled == SSL_ENABLED_TRUE) {
431431
if ((rv = ssl_run_init_server(s, p, 0, sc->server->ssl_ctx)) != APR_SUCCESS) {
432432
return rv;
433433
}
@@ -2126,9 +2126,9 @@ apr_status_t ssl_init_ConfigureServer(server_rec *s,
21262126
&ssl_module);
21272127
apr_status_t rv;
21282128

2129-
/* Initialize the server if SSL is enabled or optional.
2129+
/* Initialize the server if SSL is enabled.
21302130
*/
2131-
if ((sc->enabled == SSL_ENABLED_TRUE) || (sc->enabled == SSL_ENABLED_OPTIONAL)) {
2131+
if (sc->enabled == SSL_ENABLED_TRUE) {
21322132
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(01914)
21332133
"Configuring server %s for SSL protocol", sc->vhost_id);
21342134
if ((rv = ssl_init_server_ctx(s, p, ptemp, sc, pphrases))

modules/ssl/ssl_engine_kernel.c

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -38,59 +38,6 @@ static void ssl_configure_env(request_rec *r, SSLConnRec *sslconn);
3838
static int ssl_find_vhost(void *servername, conn_rec *c, server_rec *s);
3939
#endif
4040

41-
#define SWITCH_STATUS_LINE "HTTP/1.1 101 Switching Protocols"
42-
#define UPGRADE_HEADER "Upgrade: TLS/1.0, HTTP/1.1"
43-
#define CONNECTION_HEADER "Connection: Upgrade"
44-
45-
/* Perform an upgrade-to-TLS for the given request, per RFC 2817. */
46-
static apr_status_t upgrade_connection(request_rec *r)
47-
{
48-
struct conn_rec *conn = r->connection;
49-
apr_bucket_brigade *bb;
50-
SSLConnRec *sslconn;
51-
apr_status_t rv;
52-
SSL *ssl;
53-
54-
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(02028)
55-
"upgrading connection to TLS");
56-
57-
bb = apr_brigade_create(r->pool, conn->bucket_alloc);
58-
59-
rv = ap_fputs(conn->output_filters, bb, SWITCH_STATUS_LINE CRLF
60-
UPGRADE_HEADER CRLF CONNECTION_HEADER CRLF CRLF);
61-
if (rv == APR_SUCCESS) {
62-
APR_BRIGADE_INSERT_TAIL(bb,
63-
apr_bucket_flush_create(conn->bucket_alloc));
64-
rv = ap_pass_brigade(conn->output_filters, bb);
65-
}
66-
67-
if (rv) {
68-
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02029)
69-
"failed to send 101 interim response for connection "
70-
"upgrade");
71-
return rv;
72-
}
73-
74-
ssl_init_ssl_connection(conn, r);
75-
76-
sslconn = myConnConfig(conn);
77-
ssl = sslconn->ssl;
78-
79-
/* Perform initial SSL handshake. */
80-
SSL_set_accept_state(ssl);
81-
SSL_do_handshake(ssl);
82-
83-
if (!SSL_is_init_finished(ssl)) {
84-
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02030)
85-
"TLS upgrade handshake failed");
86-
ssl_log_ssl_error(SSLLOG_MARK, APLOG_ERR, r->server);
87-
88-
return APR_ECONNABORTED;
89-
}
90-
91-
return APR_SUCCESS;
92-
}
93-
9441
/* Perform a speculative (and non-blocking) read from the connection
9542
* filters for the given request, to determine whether there is any
9643
* pending data to read. Return non-zero if there is, else zero. */
@@ -270,40 +217,17 @@ int ssl_hook_ReadReq(request_rec *r)
270217
{
271218
SSLSrvConfigRec *sc = mySrvConfig(r->server);
272219
SSLConnRec *sslconn;
273-
const char *upgrade;
274220
#ifdef HAVE_TLSEXT
275221
const char *servername;
276222
#endif
277223
SSL *ssl;
278224

279-
/* Perform TLS upgrade here if "SSLEngine optional" is configured,
280-
* SSL is not already set up for this connection, and the client
281-
* has sent a suitable Upgrade header. */
282-
if (sc->enabled == SSL_ENABLED_OPTIONAL && !myConnConfig(r->connection)
283-
&& (upgrade = apr_table_get(r->headers_in, "Upgrade")) != NULL
284-
&& ap_find_token(r->pool, upgrade, "TLS/1.0")) {
285-
if (upgrade_connection(r)) {
286-
return AP_FILTER_ERROR;
287-
}
288-
}
289-
290225
/* If we are on a slave connection, we do not expect to have an SSLConnRec,
291226
* but our master connection might. */
292227
sslconn = myConnConfig(r->connection);
293228
if (!(sslconn && sslconn->ssl) && r->connection->master) {
294229
sslconn = myConnConfig(r->connection->master);
295230
}
296-
297-
/* If "SSLEngine optional" is configured, this is not an SSL
298-
* connection, and this isn't a subrequest, send an Upgrade
299-
* response header. Note this must happen before map_to_storage
300-
* and OPTIONS * request processing is completed.
301-
*/
302-
if (sc->enabled == SSL_ENABLED_OPTIONAL && !(sslconn && sslconn->ssl)
303-
&& !r->main) {
304-
apr_table_setn(r->headers_out, "Upgrade", "TLS/1.0, HTTP/1.1");
305-
apr_table_mergen(r->headers_out, "Connection", "upgrade");
306-
}
307231

308232
if (!sslconn) {
309233
return DECLINED;
@@ -1238,16 +1162,6 @@ int ssl_hook_Access(request_rec *r)
12381162
* Support for SSLRequireSSL directive
12391163
*/
12401164
if (dc->bSSLRequired && !ssl) {
1241-
if ((sc->enabled == SSL_ENABLED_OPTIONAL) && !r->connection->master) {
1242-
/* This vhost was configured for optional SSL, just tell the
1243-
* client that we need to upgrade.
1244-
*/
1245-
apr_table_setn(r->err_headers_out, "Upgrade", "TLS/1.0, HTTP/1.1");
1246-
apr_table_setn(r->err_headers_out, "Connection", "Upgrade");
1247-
1248-
return HTTP_UPGRADE_REQUIRED;
1249-
}
1250-
12511165
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02219)
12521166
"access to %s failed, reason: %s",
12531167
r->filename, "SSL connection required");

modules/ssl/ssl_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ typedef enum {
526526
SSL_ENABLED_UNSET = UNSET,
527527
SSL_ENABLED_FALSE = 0,
528528
SSL_ENABLED_TRUE = 1,
529-
SSL_ENABLED_OPTIONAL = 3
530529
} ssl_enabled_t;
531530

532531
/**

0 commit comments

Comments
 (0)