@ -283,7 +283,26 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
SSL_load_error_strings ( ) ;
SSLeay_add_ssl_algorithms ( ) ;
if ( ! ( cfg - > ssl_ctx = SSL_CTX_new ( client ? SSLv23_client_method ( ) : SSLv23_server_method ( ) ) ) ) {
if ( client ) {
if ( ast_test_flag ( & cfg - > flags , AST_SSL_SSLV2_CLIENT ) ) {
cfg - > ssl_ctx = SSL_CTX_new ( SSLv2_client_method ( ) ) ;
} else if ( ast_test_flag ( & cfg - > flags , AST_SSL_SSLV3_CLIENT ) ) {
cfg - > ssl_ctx = SSL_CTX_new ( SSLv3_client_method ( ) ) ;
} else if ( ast_test_flag ( & cfg - > flags , AST_SSL_TLSV1_CLIENT ) ) {
cfg - > ssl_ctx = SSL_CTX_new ( TLSv1_client_method ( ) ) ;
} else {
/* SSLv23_client_method() sends SSLv2, this was the original
* default for ssl clients before the option was given to
* pick what protocol a client should use . In order not
* to break expected behavior it remains the default . */
cfg - > ssl_ctx = SSL_CTX_new ( SSLv23_client_method ( ) ) ;
}
} else {
/* SSLv23_server_method() supports TLSv1, SSLv2, and SSLv3 inbound connections. */
cfg - > ssl_ctx = SSL_CTX_new ( SSLv23_server_method ( ) ) ;
}
if ( ! cfg - > ssl_ctx ) {
ast_debug ( 1 , " Sorry, SSL_CTX_new call returned null... \n " ) ;
cfg - > enabled = 0 ;
return 0 ;
@ -494,7 +513,7 @@ int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_
if ( ! strcasecmp ( varname , " tlsenable " ) | | ! strcasecmp ( varname , " sslenable " ) ) {
tls_cfg - > enabled = ast_true ( value ) ? 1 : 0 ;
tls_desc - > local_address . sin_family = AF_INET ;
} else if ( ! strcasecmp ( varname , " tlscertfile " ) | | ! strcasecmp ( varname , " sslcert " ) ) {
} else if ( ! strcasecmp ( varname , " tlscertfile " ) | | ! strcasecmp ( varname , " sslcert " ) | | ! strcasecmp ( varname , " tlscert " ) ) {
ast_free ( tls_cfg - > certfile ) ;
tls_cfg - > certfile = ast_strdup ( value ) ;
} else if ( ! strcasecmp ( varname , " tlsprivatekey " ) | | ! strcasecmp ( varname , " sslprivatekey " ) ) {
@ -518,6 +537,20 @@ int ast_tls_read_conf(struct ast_tls_config *tls_cfg, struct ast_tcptls_session_
ast_log ( LOG_WARNING , " Invalid %s '%s' \n " , varname , value ) ;
} else if ( ! strcasecmp ( varname , " tlsbindport " ) | | ! strcasecmp ( varname , " sslbindport " ) ) {
tls_desc - > local_address . sin_port = htons ( atoi ( value ) ) ;
} else if ( ! strcasecmp ( varname , " tlsclientmethod " ) | | ! strcasecmp ( varname , " sslclientmethod " ) ) {
if ( ! strcasecmp ( value , " tlsv1 " ) ) {
ast_set_flag ( & tls_cfg - > flags , AST_SSL_TLSV1_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_SSLV3_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_SSLV2_CLIENT ) ;
} else if ( ! strcasecmp ( value , " sslv3 " ) ) {
ast_set_flag ( & tls_cfg - > flags , AST_SSL_SSLV3_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_SSLV2_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_TLSV1_CLIENT ) ;
} else if ( ! strcasecmp ( value , " sslv2 " ) ) {
ast_set_flag ( & tls_cfg - > flags , AST_SSL_SSLV2_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_TLSV1_CLIENT ) ;
ast_clear_flag ( & tls_cfg - > flags , AST_SSL_SSLV3_CLIENT ) ;
}
} else {
return - 1 ;
}