Skip to content

Commit a39aa57

Browse files
Oleksii Dubchaksanikachavan5
authored andcommitted
fix: re-implement sslStream initialization for framework versions < 5.0
1 parent a78ffcb commit a39aa57

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Enyim.Caching/Memcached/PooledSocket.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,21 @@ void Cancel()
120120

121121
if (success)
122122
{
123-
#if NET5_0_OR_GREATER
124123
if (_useSslStream)
125124
{
126125
_sslStream = new SslStream(new NetworkStream(_socket));
127-
_sslStream.AuthenticateAsClient(_sslClientAuthOptions);
126+
_sslStream.AuthenticateAsClient(
127+
#if NET5_0_OR_GREATER
128+
_sslClientAuthOptions
129+
#else
130+
((DnsEndPoint)_endpoint).Host
131+
#endif
132+
);
128133
}
129134
else
130135
{
131136
_inputStream = new NetworkStream(_socket);
132137
}
133-
#else
134-
_inputStream = new NetworkStream(_socket);
135-
#endif
136138
}
137139
else
138140
{
@@ -185,19 +187,21 @@ public async Task ConnectAsync()
185187

186188
if (success)
187189
{
188-
#if NET5_0_OR_GREATER
189190
if (_useSslStream)
190191
{
191192
_sslStream = new SslStream(new NetworkStream(_socket));
192-
await _sslStream.AuthenticateAsClientAsync(_sslClientAuthOptions);
193+
await _sslStream.AuthenticateAsClientAsync(
194+
#if NET5_0_OR_GREATER
195+
_sslClientAuthOptions
196+
#else
197+
((DnsEndPoint)_endpoint).Host
198+
#endif
199+
);
193200
}
194201
else
195202
{
196203
_inputStream = new NetworkStream(_socket);
197204
}
198-
#else
199-
_inputStream = new NetworkStream(_socket);
200-
#endif
201205
}
202206
else
203207
{

0 commit comments

Comments
 (0)