@@ -474,6 +474,7 @@ static apr_status_t ssl_init_ctx_tls_extensions(server_rec *s,
474474}
475475#endif
476476
477+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
477478/*
478479 * Enable/disable SSLProtocol. If the mod_ssl enables protocol
479480 * which is disabled by default by OpenSSL, show a warning.
@@ -499,6 +500,7 @@ static void ssl_set_ctx_protocol_option(server_rec *s,
499500 "by OpenSSL by default on this system" , name );
500501 }
501502}
503+ #endif
502504
503505static apr_status_t ssl_init_ctx_protocol (server_rec * s ,
504506 apr_pool_t * p ,
@@ -510,6 +512,9 @@ static apr_status_t ssl_init_ctx_protocol(server_rec *s,
510512 char * cp ;
511513 int protocol = mctx -> protocol ;
512514 SSLSrvConfigRec * sc = mySrvConfig (s );
515+ #if OPENSSL_VERSION_NUMBER >= 0x10100000L
516+ int prot ;
517+ #endif
513518
514519 /*
515520 * Create the new per-server SSL context
@@ -535,6 +540,7 @@ static apr_status_t ssl_init_ctx_protocol(server_rec *s,
535540 ap_log_error (APLOG_MARK , APLOG_TRACE3 , 0 , s ,
536541 "Creating new SSL context (protocols: %s)" , cp );
537542
543+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
538544#ifndef OPENSSL_NO_SSL3
539545 if (protocol == SSL_PROTOCOL_SSLV3 ) {
540546 method = mctx -> pkp ?
@@ -565,12 +571,18 @@ static apr_status_t ssl_init_ctx_protocol(server_rec *s,
565571 SSLv23_client_method () : /* proxy */
566572 SSLv23_server_method (); /* server */
567573 }
574+ #else
575+ method = mctx -> pkp ?
576+ TLS_client_method () : /* proxy */
577+ TLS_server_method (); /* server */
578+ #endif
568579 ctx = SSL_CTX_new (method );
569580
570581 mctx -> ssl_ctx = ctx ;
571582
572583 SSL_CTX_set_options (ctx , SSL_OP_ALL );
573584
585+ #if OPENSSL_VERSION_NUMBER < 0x10100000L
574586 /* always disable SSLv2, as per RFC 6176 */
575587 SSL_CTX_set_options (ctx , SSL_OP_NO_SSLv2 );
576588
@@ -589,6 +601,43 @@ static apr_status_t ssl_init_ctx_protocol(server_rec *s,
589601 protocol & SSL_PROTOCOL_TLSV1_2 , "TLSv1.2" );
590602#endif
591603
604+ #else /* #if OPENSSL_VERSION_NUMBER < 0x10100000L */
605+ /* We first determine the maximum protocol version we should provide */
606+ if (protocol & SSL_PROTOCOL_TLSV1_2 ) {
607+ prot = TLS1_2_VERSION ;
608+ } else if (protocol & SSL_PROTOCOL_TLSV1_1 ) {
609+ prot = TLS1_1_VERSION ;
610+ } else if (protocol & SSL_PROTOCOL_TLSV1 ) {
611+ prot = TLS1_VERSION ;
612+ #ifndef OPENSSL_NO_SSL3
613+ } else if (protocol & SSL_PROTOCOL_SSLV3 ) {
614+ prot = SSL3_VERSION ;
615+ #endif
616+ } else {
617+ SSL_CTX_free (ctx );
618+ mctx -> ssl_ctx = NULL ;
619+ ap_log_error (APLOG_MARK , APLOG_EMERG , 0 , s , APLOGNO ()
620+ "No SSL protocols available [hint: SSLProtocol]" );
621+ return ssl_die (s );
622+ }
623+ SSL_CTX_set_max_proto_version (ctx , prot );
624+
625+ /* Next we scan for the minimal protocol version we should provide,
626+ * but we do not allow holes between max and min */
627+ if (prot == TLS1_2_VERSION && protocol & SSL_PROTOCOL_TLSV1_1 ) {
628+ prot = TLS1_1_VERSION ;
629+ }
630+ if (prot == TLS1_1_VERSION && protocol & SSL_PROTOCOL_TLSV1 ) {
631+ prot = TLS1_VERSION ;
632+ }
633+ #ifndef OPENSSL_NO_SSL3
634+ if (prot == TLS1_VERSION && protocol & SSL_PROTOCOL_SSLV3 ) {
635+ prot = SSL3_VERSION ;
636+ }
637+ #endif
638+ SSL_CTX_set_min_proto_version (ctx , prot );
639+ #endif /* if OPENSSL_VERSION_NUMBER < 0x10100000L */
640+
592641#ifdef SSL_OP_CIPHER_SERVER_PREFERENCE
593642 if (sc -> cipher_server_pref == TRUE) {
594643 SSL_CTX_set_options (ctx , SSL_OP_CIPHER_SERVER_PREFERENCE );
0 commit comments