@@ -38,6 +38,7 @@ public class TTlsSocketTransport : TStreamTransport
3838 private readonly LocalCertificateSelectionCallback _localCertificateSelectionCallback ;
3939 private readonly int _port ;
4040 private readonly SslProtocols _sslProtocols ;
41+ private readonly string _targetHost ;
4142 private TcpClient _client ;
4243 private SslStream _secureStream ;
4344 private int _timeout ;
@@ -122,13 +123,13 @@ public TTlsSocketTransport(string host, int port, TConfiguration config, int tim
122123 {
123124 try
124125 {
126+ _targetHost = host ;
127+
125128 var entry = Dns . GetHostEntry ( host ) ;
126129 if ( entry . AddressList . Length == 0 )
127130 throw new TTransportException ( TTransportException . ExceptionType . Unknown , "unable to resolve host name" ) ;
128131
129- var addr = entry . AddressList [ 0 ] ;
130-
131- _host = new IPAddress ( addr . GetAddressBytes ( ) , addr . ScopeId ) ;
132+ _host = entry . AddressList [ 0 ] ;
132133 _port = port ;
133134 _timeout = timeout ;
134135 _certificate = certificate ;
@@ -239,7 +240,7 @@ public async Task SetupTlsAsync()
239240 ? new X509CertificateCollection { _certificate }
240241 : new X509CertificateCollection ( ) ;
241242
242- var targetHost = _host . ToString ( ) ;
243+ var targetHost = _targetHost ?? _host . ToString ( ) ;
243244 await _secureStream . AuthenticateAsClientAsync ( targetHost , certs , _sslProtocols , true ) ;
244245 }
245246 }
0 commit comments