mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Prequisites for ARI Outbound Websockets
stasis: * Added stasis_app_is_registered(). * Added stasis_app_control_mark_failed(). * Added stasis_app_control_is_failed(). * Fixed res_stasis_device_state so unsubscribe all works properly. * Modified stasis_app_unregister() to unsubscribe from all event sources. * Modified stasis_app_exec to return -1 if stasis_app_control_is_failed() returns true. http: * Added ast_http_create_basic_auth_header(). md5: * Added define for MD5_DIGEST_LENGTH. tcptls: * Added flag to ast_tcptls_session_args to suppress connection log messages to give callers more control over logging. http_websocket: * Add flag to ast_websocket_client_options to suppress connection log messages to give callers more control over logging. * Added username and password to ast_websocket_client_options to support outbound basic authentication. * Added ast_websocket_result_to_str().
This commit is contained in:
@@ -379,7 +379,8 @@ static void __ssl_setup_certs(struct ast_tls_config *cfg, const size_t cert_file
|
||||
}
|
||||
#endif
|
||||
|
||||
static int __ssl_setup(struct ast_tls_config *cfg, int client)
|
||||
static int __ssl_setup(struct ast_tls_config *cfg, int client,
|
||||
int suppress_progress_msgs)
|
||||
{
|
||||
#ifndef DO_SSL
|
||||
if (cfg->enabled) {
|
||||
@@ -534,7 +535,9 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
|
||||
if (SSL_CTX_set_tmp_dh(cfg->ssl_ctx, dh)) {
|
||||
long options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_SINGLE_DH_USE | SSL_OP_SINGLE_ECDH_USE;
|
||||
options = SSL_CTX_set_options(cfg->ssl_ctx, options);
|
||||
ast_verb(2, "TLS/SSL DH initialized, PFS cipher-suites enabled\n");
|
||||
if (!suppress_progress_msgs) {
|
||||
ast_verb(2, "TLS/SSL DH initialized, PFS cipher-suites enabled\n");
|
||||
}
|
||||
}
|
||||
DH_free(dh);
|
||||
}
|
||||
@@ -548,7 +551,9 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
|
||||
#endif
|
||||
/* SSL_CTX_set_ecdh_auto(cfg->ssl_ctx, on); requires OpenSSL 1.0.2 which wraps: */
|
||||
if (SSL_CTX_ctrl(cfg->ssl_ctx, SSL_CTRL_SET_ECDH_AUTO, 1, NULL)) {
|
||||
ast_verb(2, "TLS/SSL ECDH initialized (automatic), faster PFS ciphers enabled\n");
|
||||
if (!suppress_progress_msgs) {
|
||||
ast_verb(2, "TLS/SSL ECDH initialized (automatic), faster PFS ciphers enabled\n");
|
||||
}
|
||||
#if !defined(OPENSSL_NO_ECDH) && (OPENSSL_VERSION_NUMBER >= 0x10000000L) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
} else {
|
||||
/* enables AES-128 ciphers, to get AES-256 use NID_secp384r1 */
|
||||
@@ -562,14 +567,16 @@ static int __ssl_setup(struct ast_tls_config *cfg, int client)
|
||||
#endif
|
||||
}
|
||||
|
||||
ast_verb(2, "TLS/SSL certificate ok\n"); /* We should log which one that is ok. This message doesn't really make sense in production use */
|
||||
if (!suppress_progress_msgs) {
|
||||
ast_verb(2, "TLS/SSL certificate ok\n"); /* We should log which one that is ok. This message doesn't really make sense in production use */
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ast_ssl_setup(struct ast_tls_config *cfg)
|
||||
{
|
||||
return __ssl_setup(cfg, 0);
|
||||
return __ssl_setup(cfg, 0, 0);
|
||||
}
|
||||
|
||||
void ast_ssl_teardown(struct ast_tls_config *cfg)
|
||||
@@ -653,8 +660,10 @@ struct ast_tcptls_session_instance *ast_tcptls_client_start_timeout(
|
||||
}
|
||||
|
||||
if (socket_connect(desc->accept_fd, &desc->remote_address, timeout)) {
|
||||
ast_log(LOG_WARNING, "Unable to connect %s to %s: %s\n", desc->name,
|
||||
ast_sockaddr_stringify(&desc->remote_address), strerror(errno));
|
||||
if (!desc->suppress_connection_msgs) {
|
||||
ast_log(LOG_WARNING, "Unable to connect %s to %s: %s\n", desc->name,
|
||||
ast_sockaddr_stringify(&desc->remote_address), strerror(errno));
|
||||
}
|
||||
|
||||
ao2_ref(tcptls_session, -1);
|
||||
return NULL;
|
||||
@@ -663,8 +672,7 @@ struct ast_tcptls_session_instance *ast_tcptls_client_start_timeout(
|
||||
ast_fd_clear_flags(desc->accept_fd, O_NONBLOCK);
|
||||
|
||||
if (desc->tls_cfg) {
|
||||
desc->tls_cfg->enabled = 1;
|
||||
__ssl_setup(desc->tls_cfg, 1);
|
||||
__ssl_setup(desc->tls_cfg, 1, desc->suppress_connection_msgs);
|
||||
}
|
||||
|
||||
return handle_tcptls_connection(tcptls_session);
|
||||
|
Reference in New Issue
Block a user