@@ -38,59 +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- 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" );
0 commit comments