Fix cherry picked commit.

pull/1907/head
Roger A. Light 5 years ago
parent b81f0d6782
commit 4e3b8ed2b5

@ -855,16 +855,6 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
#endif
void net__socket_close_compat(struct mosquitto *mosq)
{
#ifdef WITH_BROKER
struct mosquitto_db *db = mosquitto__get_db();
net__socket_close(db, mosq);
#else
net__socket_close(mosq);
#endif
}
int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
{
#ifdef WITH_TLS
@ -872,7 +862,7 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
int rc = net__init_ssl_ctx(mosq);
if(rc){
net__socket_close_compat(mosq);
net__socket_close(mosq);
return rc;
}
@ -882,7 +872,7 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
}
mosq->ssl = SSL_new(mosq->ssl_ctx);
if(!mosq->ssl){
net__socket_close_compat(mosq);
net__socket_close(mosq);
net__print_ssl_error(mosq);
return MOSQ_ERR_TLS;
}
@ -890,7 +880,7 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
SSL_set_ex_data(mosq->ssl, tls_ex_index_mosq, mosq);
bio = BIO_new_socket(mosq->sock, BIO_NOCLOSE);
if(!bio){
net__socket_close_compat(mosq);
net__socket_close(mosq);
net__print_ssl_error(mosq);
return MOSQ_ERR_TLS;
}
@ -900,12 +890,12 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
* required for the SNI resolving
*/
if(SSL_set_tlsext_host_name(mosq->ssl, host) != 1) {
net__socket_close_compat(mosq);
net__socket_close(mosq);
return MOSQ_ERR_TLS;
}
if(net__socket_connect_tls(mosq)){
net__socket_close_compat(mosq);
net__socket_close(mosq);
return MOSQ_ERR_TLS;
}

Loading…
Cancel
Save