Skip to content

Commit 63f48bb

Browse files
committed
remove antiquated 'SSLEngine optional' TLS upgrade
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1927037 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3492480 commit 63f48bb

File tree

4 files changed

+7
-94
lines changed

4 files changed

+7
-94
lines changed

modules/ssl/ssl_engine_config.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,11 +831,13 @@ const char *ssl_cmd_SSLEngine(cmd_parms *cmd, void *dcfg, const char *arg)
831831
return NULL;
832832
}
833833
else if (!strcasecmp(arg, "Optional")) {
834-
sc->enabled = SSL_ENABLED_OPTIONAL;
834+
sc->enabled = SSL_ENABLED_FALSE;
835+
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, cmd->server, APLOGNO(10510)
836+
"'SSLEngine optional' is no longer supported");
835837
return NULL;
836838
}
837839

838-
return "Argument must be On, Off, or Optional";
840+
return "Argument must be On or Off";
839841
}
840842

841843
const char *ssl_cmd_SSLFIPS(cmd_parms *cmd, void *dcfg, int flag)
@@ -2442,9 +2444,6 @@ static void val_enabled_dump(apr_file_t *out, const char *key, ssl_enabled_t val
24422444
case SSL_ENABLED_TRUE:
24432445
val_str_dump(out, key, "on", p, indent, psep);
24442446
return;
2445-
case SSL_ENABLED_OPTIONAL:
2446-
val_str_dump(out, key, "optional", p, indent, psep);
2447-
return;
24482447
default:
24492448
return;
24502449
}

modules/ssl/ssl_engine_init.c

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

445445
sc = mySrvConfig(s);
446-
if (sc->enabled == SSL_ENABLED_TRUE || sc->enabled == SSL_ENABLED_OPTIONAL) {
446+
if (sc->enabled == SSL_ENABLED_TRUE) {
447447
if ((rv = ssl_run_init_server(s, p, 0, sc->server->ssl_ctx)) != APR_SUCCESS) {
448448
return rv;
449449
}
@@ -2165,9 +2165,9 @@ apr_status_t ssl_init_ConfigureServer(server_rec *s,
21652165
&ssl_module);
21662166
apr_status_t rv;
21672167

2168-
/* Initialize the server if SSL is enabled or optional.
2168+
/* Initialize the server if SSL is enabled.
21692169
*/
2170-
if ((sc->enabled == SSL_ENABLED_TRUE) || (sc->enabled == SSL_ENABLED_OPTIONAL)) {
2170+
if (sc->enabled == SSL_ENABLED_TRUE) {
21712171
ap_log_error(APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(01914)
21722172
"Configuring server %s for SSL protocol", sc->vhost_id);
21732173
if ((rv = ssl_init_server_ctx(s, p, ptemp, sc, pphrases))

modules/ssl/ssl_engine_kernel.c

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -38,58 +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-
82-
if ((SSL_do_handshake(ssl) != 1) || !SSL_is_init_finished(ssl)) {
83-
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02030)
84-
"TLS upgrade handshake failed");
85-
ssl_log_ssl_error(SSLLOG_MARK, APLOG_ERR, r->server);
86-
87-
return APR_ECONNABORTED;
88-
}
89-
90-
return APR_SUCCESS;
91-
}
92-
9341
/* Perform a speculative (and non-blocking) read from the connection
9442
* filters for the given request, to determine whether there is any
9543
* pending data to read. Return non-zero if there is, else zero. */
@@ -269,40 +217,17 @@ int ssl_hook_ReadReq(request_rec *r)
269217
{
270218
SSLSrvConfigRec *sc = mySrvConfig(r->server);
271219
SSLConnRec *sslconn;
272-
const char *upgrade;
273220
#ifdef HAVE_TLSEXT
274221
const char *servername;
275222
#endif
276223
SSL *ssl;
277224

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

307232
if (!sslconn) {
308233
return DECLINED;
@@ -1250,16 +1175,6 @@ int ssl_hook_Access(request_rec *r)
12501175
* Support for SSLRequireSSL directive
12511176
*/
12521177
if (dc->bSSLRequired && !ssl) {
1253-
if ((sc->enabled == SSL_ENABLED_OPTIONAL) && !r->connection->master) {
1254-
/* This vhost was configured for optional SSL, just tell the
1255-
* client that we need to upgrade.
1256-
*/
1257-
apr_table_setn(r->err_headers_out, "Upgrade", "TLS/1.0, HTTP/1.1");
1258-
apr_table_setn(r->err_headers_out, "Connection", "Upgrade");
1259-
1260-
return HTTP_UPGRADE_REQUIRED;
1261-
}
1262-
12631178
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02219)
12641179
"access to %s failed, reason: %s",
12651180
r->filename, "SSL connection required");

modules/ssl/ssl_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ typedef enum {
518518
SSL_ENABLED_UNSET = UNSET,
519519
SSL_ENABLED_FALSE = 0,
520520
SSL_ENABLED_TRUE = 1,
521-
SSL_ENABLED_OPTIONAL = 3
522521
} ssl_enabled_t;
523522

524523
/**

0 commit comments

Comments
 (0)