@@ -209,7 +209,15 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
209209 boost::asio::ssl::context ctx (executor_->getIOService (), boost::asio::ssl::context::tlsv1_client);
210210#endif
211211 Url serviceUrl;
212+ Url proxyUrl;
212213 Url::parse (physicalAddress, serviceUrl);
214+ proxyServiceUrl_ = clientConfiguration.getProxyServiceUrl ();
215+ proxyProtocol_ = clientConfiguration.getProxyProtocol ();
216+ if (proxyProtocol_ == ClientConfiguration::SNI && !proxyServiceUrl_.empty ()) {
217+ Url::parse (proxyServiceUrl_, proxyUrl);
218+ isSniProxy_ = true ;
219+ LOG_INFO (" Configuring SNI Proxy-url=" << proxyServiceUrl_);
220+ }
213221 if (clientConfiguration.isTlsAllowInsecureConnection ()) {
214222 ctx.set_verify_mode (boost::asio::ssl::context::verify_none);
215223 isTlsAllowInsecureConnection_ = true ;
@@ -257,7 +265,8 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
257265
258266 if (!clientConfiguration.isTlsAllowInsecureConnection () && clientConfiguration.isValidateHostName ()) {
259267 LOG_DEBUG (" Validating hostname for " << serviceUrl.host () << " :" << serviceUrl.port ());
260- tlsSocket_->set_verify_callback (boost::asio::ssl::rfc2818_verification (serviceUrl.host ()));
268+ std::string urlHost = isSniProxy_ ? proxyUrl.host () : serviceUrl.host ();
269+ tlsSocket_->set_verify_callback (boost::asio::ssl::rfc2818_verification (urlHost));
261270 }
262271
263272 LOG_DEBUG (" TLS SNI Host: " << serviceUrl.host ());
@@ -403,7 +412,8 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
403412 if (logicalAddress_ == physicalAddress_) {
404413 LOG_INFO (cnxString_ << " Connected to broker" );
405414 } else {
406- LOG_INFO (cnxString_ << " Connected to broker through proxy. Logical broker: " << logicalAddress_);
415+ LOG_INFO (cnxString_ << " Connected to broker through proxy. Logical broker: " << logicalAddress_
416+ << " , proxy: " << proxyServiceUrl_);
407417 }
408418
409419 Lock lock (mutex_);
@@ -572,7 +582,8 @@ void ClientConnection::tcpConnectAsync() {
572582
573583 boost::system::error_code err;
574584 Url service_url;
575- if (!Url::parse (physicalAddress_, service_url)) {
585+ std::string hostUrl = isSniProxy_ ? proxyServiceUrl_ : physicalAddress_;
586+ if (!Url::parse (hostUrl, service_url)) {
576587 LOG_ERROR (cnxString_ << " Invalid Url, unable to parse: " << err << " " << err.message ());
577588 close ();
578589 return ;
@@ -600,7 +611,8 @@ void ClientConnection::tcpConnectAsync() {
600611void ClientConnection::handleResolve (const boost::system::error_code& err,
601612 tcp::resolver::iterator endpointIterator) {
602613 if (err) {
603- LOG_ERROR (cnxString_ << " Resolve error: " << err << " : " << err.message ());
614+ std::string hostUrl = isSniProxy_ ? cnxString_ : proxyServiceUrl_;
615+ LOG_ERROR (hostUrl << " Resolve error: " << err << " : " << err.message ());
604616 close ();
605617 return ;
606618 }
0 commit comments