@@ -158,6 +158,8 @@ static apr_pool_t *recv_pool = NULL;
158
158
static apr_array_header_t * queue = NULL ;
159
159
static const char * queue_path = NULL ;
160
160
static int ssl_validation = 0 ;
161
+ static int tlsprotocol = 1 ;
162
+ static curl_version_info_data * curlversion = NULL ;
161
163
/* static apr_time_t queue_time = 0; */
162
164
static void * requestline_regex = NULL ;
163
165
static int running = 0 ;
@@ -810,6 +812,26 @@ static void init_configuration(void)
810
812
startup_delay = atoi (s );
811
813
}
812
814
815
+ /* TLS Protocol - TLSv1(0) TLSv1.1(1) TLSv1.2(2) (SSLv3 not supported) */
816
+ s = apr_table_get (conf , "TLSProtocol" );
817
+ if (s != NULL ) {
818
+ int num = atoi (s );
819
+ switch (num ) {
820
+ case 0 :
821
+ tlsprotocol = 0 ;
822
+ break ;
823
+ case 1 :
824
+ tlsprotocol = 1 ;
825
+ break ;
826
+ case 2 :
827
+ tlsprotocol = 2 ;
828
+ break ;
829
+ default :
830
+ tlsprotocol = 2 ; /* Default is TLSv1.2 */
831
+ }
832
+ }
833
+ curlversion = curl_version_info (CURLVERSION_NOW );
834
+
813
835
if ( startup_delay > 0 ) {
814
836
error_log (LOG_NOTICE , NULL ,
815
837
"Delaying execution for %dms." , startup_delay );
@@ -824,6 +846,8 @@ static void init_configuration(void)
824
846
error_log (LOG_DEBUG2 , NULL , "ErrorLog=%s" , error_log_path );
825
847
error_log (LOG_DEBUG2 , NULL , "ErrorLogLevel=%d" , error_log_level );
826
848
error_log (LOG_DEBUG2 , NULL , "StartupDelay=%d" , startup_delay );
849
+ error_log (LOG_DEBUG2 , NULL , "TLSProtocol=%d" , tlsprotocol );
850
+ error_log (LOG_DEBUG2 , NULL , "cURL version=%s" , curlversion -> version );
827
851
828
852
s = apr_table_get (conf , "CheckpointInterval" );
829
853
if (s != NULL ) {
@@ -1182,6 +1206,8 @@ static void logc_init(void)
1182
1206
apr_status_t rc = 0 ;
1183
1207
const char * errptr = NULL ;
1184
1208
int i , erroffset ;
1209
+ /* cURL major, minor and patch version */
1210
+ short cmaj , cmin , cpat = 0 ;
1185
1211
1186
1212
queue = apr_array_make (pool , 64 , sizeof (entry_t * ));
1187
1213
if (queue == NULL ) {
@@ -1246,8 +1272,31 @@ static void logc_init(void)
1246
1272
1247
1273
/* Seems like CURL_SSLVERSION_TLSv1_2 is not supported on libcurl
1248
1274
* < v7.34.0
1275
+ *
1276
+ * version_num is a 24 bit number created like this:
1277
+ * <8 bits major number> | <8 bits minor number> | <8 bits patch number>.
1249
1278
*/
1250
- curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1 );
1279
+ switch (tlsprotocol ) {
1280
+ case 0 :
1281
+ curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_0 );
1282
+ break ;
1283
+ case 1 :
1284
+ curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_1 );
1285
+ break ;
1286
+ case 2 :
1287
+ curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_2 );
1288
+ break ;
1289
+ default :
1290
+ curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_2 );
1291
+ break ;
1292
+ }
1293
+ cmaj = curlversion -> version_num >> 16 ;
1294
+ cmin = (curlversion -> version_num & 0x00ff00 ) >> 8 ;
1295
+ cpat = (curlversion -> version_num & 0x0000ff );
1296
+ /* If cURL version < v7.34.0, use TLS v1.x */
1297
+ if (cmaj <= 7 && cmin < 34 ) {
1298
+ curl_easy_setopt (curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1 );
1299
+ }
1251
1300
1252
1301
curl_easy_setopt (curl , CURLOPT_CONNECTTIMEOUT , 15 );
1253
1302
curl_easy_setopt (curl , CURLOPT_NOSIGNAL , TRUE);
@@ -1258,6 +1307,10 @@ static void logc_init(void)
1258
1307
* (CURL * * )apr_array_push (curl_handles ) = curl ;
1259
1308
}
1260
1309
1310
+ if (cmaj <= 7 && cmin < 34 ) {
1311
+ error_log (LOG_DEBUG2 , NULL , "TLSv1.2 is unsupported in cURL %d.%d.%d" , cmaj , cmin , cpat );
1312
+ }
1313
+
1261
1314
logline_regex = pcre_compile (logline_pattern , PCRE_CASELESS ,
1262
1315
& errptr , & erroffset , NULL );
1263
1316
if (logline_regex == NULL ) {
0 commit comments