@@ -38,58 +38,6 @@ static void ssl_configure_env(request_rec *r, SSLConnRec *sslconn);
3838static 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" );
0 commit comments