diff --git a/ChangeLog.txt b/ChangeLog.txt index 79c6bbe4..48a7614b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,9 @@ Broker: - Fixed comment handling for config options that have optional arguments. +Library: +- Fix TLS connections not working over SOCKS. + Build: - Fix comparison of boolean values in CMake build. Closes #1101. - Fix compilation when openssl deprecated APIs are not available. diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 6ff60a93..2473da4c 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -610,7 +610,7 @@ static int net__init_ssl_ctx(struct mosquitto *mosq) #endif -int net__socket_connect_step3(struct mosquitto *mosq, const char *host, uint16_t port, const char *bind_address, bool blocking) +int net__socket_connect_step3(struct mosquitto *mosq, const char *host) { #ifdef WITH_TLS BIO *bio; @@ -671,8 +671,13 @@ int net__socket_connect(struct mosquitto *mosq, const char *host, uint16_t port, mosq->sock = sock; - rc = net__socket_connect_step3(mosq, host, port, bind_address, blocking); - if(rc) return rc; +#ifdef WITH_SOCKS + if(!mosq->socks5_host) +#endif + { + rc = net__socket_connect_step3(mosq, host); + if(rc) return rc; + } return MOSQ_ERR_SUCCESS; } diff --git a/lib/net_mosq.h b/lib/net_mosq.h index ea729665..702034db 100644 --- a/lib/net_mosq.h +++ b/lib/net_mosq.h @@ -61,7 +61,7 @@ int net__socket_close(struct mosquitto *mosq); int net__try_connect(struct mosquitto *mosq, const char *host, uint16_t port, mosq_sock_t *sock, const char *bind_address, bool blocking); int net__try_connect_step1(struct mosquitto *mosq, const char *host); int net__try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_sock_t *sock); -int net__socket_connect_step3(struct mosquitto *mosq, const char *host, uint16_t port, const char *bind_address, bool blocking); +int net__socket_connect_step3(struct mosquitto *mosq, const char *host); int net__socket_nonblock(mosq_sock_t *sock); int net__socketpair(mosq_sock_t *sp1, mosq_sock_t *sp2); diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index e7d597f7..ea524c1f 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -424,6 +424,10 @@ int socks5__read(struct mosquitto *mosq) /* Auth passed */ packet__cleanup(&mosq->in_packet); mosq->state = mosq_cs_new; + if(mosq->socks5_host){ + int rc = net__socket_connect_step3(mosq, mosq->host); + if(rc) return rc; + } return send__connect(mosq, mosq->keepalive, mosq->clean_session); }else{ i = mosq->in_packet.payload[1];