Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f247bb6

Browse files
committed
Also use ConnectTimeout when establishing an SSL connection
1 parent 52f25b4 commit f247bb6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/ServiceStack.Redis/RedisNativeClient_Utils.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private void Connect()
144144
}
145145
else
146146
{
147-
#if NETSTANDARD2_0
147+
#if NETSTANDARD || NET472
148148
sslStream = new SslStream(networkStream,
149149
leaveInnerStreamOpen: false,
150150
userCertificateValidationCallback: RedisConfig.CertificateValidationCallback,
@@ -167,17 +167,26 @@ private void Connect()
167167
#endif
168168
}
169169

170-
#if NETSTANDARD2_0
171-
sslStream.AuthenticateAsClientAsync(Host).Wait();
170+
#if NETSTANDARD || NET472
171+
var task = sslStream.AuthenticateAsClientAsync(Host);
172+
if (ConnectTimeout > 0)
173+
{
174+
task.Wait(ConnectTimeout);
175+
}
176+
else
177+
{
178+
task.Wait();
179+
}
172180
#else
173181
if (SslProtocols != null)
174182
{
175-
sslStream.AuthenticateAsClient(Host, new X509CertificateCollection(), SslProtocols ?? System.Security.Authentication.SslProtocols.Default, checkCertificateRevocation: true);
176-
} else
183+
sslStream.AuthenticateAsClient(Host, new X509CertificateCollection(),
184+
SslProtocols ?? System.Security.Authentication.SslProtocols.None, checkCertificateRevocation: true);
185+
}
186+
else
177187
{
178188
sslStream.AuthenticateAsClient(Host);
179189
}
180-
181190
#endif
182191

183192
if (!sslStream.IsEncrypted)

0 commit comments

Comments
 (0)