@@ -38,6 +38,7 @@ public class TTlsSocketTransport : TStreamTransport
38
38
private readonly LocalCertificateSelectionCallback _localCertificateSelectionCallback ;
39
39
private readonly int _port ;
40
40
private readonly SslProtocols _sslProtocols ;
41
+ private readonly string _targetHost ;
41
42
private TcpClient _client ;
42
43
private SslStream _secureStream ;
43
44
private int _timeout ;
@@ -122,13 +123,13 @@ public TTlsSocketTransport(string host, int port, TConfiguration config, int tim
122
123
{
123
124
try
124
125
{
126
+ _targetHost = host ;
127
+
125
128
var entry = Dns . GetHostEntry ( host ) ;
126
129
if ( entry . AddressList . Length == 0 )
127
130
throw new TTransportException ( TTransportException . ExceptionType . Unknown , "unable to resolve host name" ) ;
128
131
129
- var addr = entry . AddressList [ 0 ] ;
130
-
131
- _host = new IPAddress ( addr . GetAddressBytes ( ) , addr . ScopeId ) ;
132
+ _host = entry . AddressList [ 0 ] ;
132
133
_port = port ;
133
134
_timeout = timeout ;
134
135
_certificate = certificate ;
@@ -239,7 +240,7 @@ public async Task SetupTlsAsync()
239
240
? new X509CertificateCollection { _certificate }
240
241
: new X509CertificateCollection ( ) ;
241
242
242
- var targetHost = _host . ToString ( ) ;
243
+ var targetHost = _targetHost ?? _host . ToString ( ) ;
243
244
await _secureStream . AuthenticateAsClientAsync ( targetHost , certs , _sslProtocols , true ) ;
244
245
}
245
246
}
0 commit comments