@@ -162,6 +162,8 @@ struct ssl_config_file {
162162static struct ssl_config_file private_key ;
163163static struct ssl_config_file certificate ;
164164static struct ssl_config_file ca_cert ;
165+ static char * ssl_protocols = "TLSv1,TLSv1.1,TLSv1.2" ;
166+ static char * ssl_ciphers = "HIGH:!aNULL:!MD5" ;
165167
166168/* Ordinarily, the SSL client and server verify each other's certificates using
167169 * a CA certificate. Setting this to false disables this behavior. (This is a
@@ -966,6 +968,7 @@ do_ssl_init(void)
966968 SSL_CTX_set_verify (ctx , SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT ,
967969 NULL );
968970 SSL_CTX_set_session_cache_mode (ctx , SSL_SESS_CACHE_OFF );
971+ SSL_CTX_set_cipher_list (ctx , "HIGH:!aNULL:!MD5" );
969972
970973 return 0 ;
971974}
@@ -1114,6 +1117,68 @@ stream_ssl_set_key_and_cert(const char *private_key_file,
11141117 }
11151118}
11161119
1120+ /* Sets SSL ciphers based on string input. Aborts with an error message
1121+ * if 'arg' is invalid. */
1122+ void
1123+ stream_ssl_set_ciphers (const char * arg )
1124+ {
1125+ if (ssl_init () || !arg || !strcmp (ssl_ciphers , arg )) {
1126+ return ;
1127+ }
1128+ if (SSL_CTX_set_cipher_list (ctx ,arg ) == 0 ) {
1129+ VLOG_ERR ("SSL_CTX_set_cipher_list: %s" ,
1130+ ERR_error_string (ERR_get_error (), NULL ));
1131+ }
1132+ ssl_ciphers = xstrdup (arg );
1133+ }
1134+
1135+ /* Set SSL protocols based on the string input. Aborts with an error message
1136+ * if 'arg' is invalid. */
1137+ void
1138+ stream_ssl_set_protocols (const char * arg )
1139+ {
1140+ if (ssl_init () || !arg || !strcmp (arg , ssl_protocols )){
1141+ return ;
1142+ }
1143+
1144+ /* Start with all the flags off and turn them on as requested. */
1145+ long protocol_flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 ;
1146+ protocol_flags |= SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 ;
1147+
1148+ char * s = xstrdup (arg );
1149+ char * save_ptr = NULL ;
1150+ char * word = strtok_r (s , " ,\t" , & save_ptr );
1151+ if (word == NULL ) {
1152+ VLOG_ERR ("SSL protocol settings invalid" );
1153+ goto exit ;
1154+ }
1155+ while (word != NULL ) {
1156+ long on_flag ;
1157+ if (!strcasecmp (word , "TLSv1.2" )){
1158+ on_flag = SSL_OP_NO_TLSv1_2 ;
1159+ } else if (!strcasecmp (word , "TLSv1.1" )){
1160+ on_flag = SSL_OP_NO_TLSv1_1 ;
1161+ } else if (!strcasecmp (word , "TLSv1" )){
1162+ on_flag = SSL_OP_NO_TLSv1 ;
1163+ } else {
1164+ VLOG_ERR ("%s: SSL protocol not recognized" , word );
1165+ goto exit ;
1166+ }
1167+ /* Reverse the no flag and mask it out in the flags
1168+ * to turn on that protocol. */
1169+ protocol_flags &= ~on_flag ;
1170+ word = strtok_r (NULL , " ,\t" , & save_ptr );
1171+ };
1172+
1173+ /* Set the actual options. */
1174+ SSL_CTX_set_options (ctx , protocol_flags );
1175+
1176+ ssl_protocols = xstrdup (arg );
1177+
1178+ exit :
1179+ free (s );
1180+ }
1181+
11171182/* Reads the X509 certificate or certificates in file 'file_name'. On success,
11181183 * stores the address of the first element in an array of pointers to
11191184 * certificates in '*certs' and the number of certificates in the array in
0 commit comments