Skip to content

Commit 99eabb9

Browse files
authored
Merge pull request #231 from alex-dubchak/main
fix: re-implement sslStream initialization for framework versions < 5.0
2 parents 9dd3b7b + 05112f9 commit 99eabb9

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Enyim.Caching/Memcached/PooledSocket.cs

+14-10
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,21 @@ void Cancel()
118118

119119
if (success)
120120
{
121-
#if NET5_0_OR_GREATER
122121
if (_useSslStream)
123122
{
124123
_sslStream = new SslStream(new NetworkStream(_socket));
125-
_sslStream.AuthenticateAsClient(_sslClientAuthOptions);
124+
_sslStream.AuthenticateAsClient(
125+
#if NET5_0_OR_GREATER
126+
_sslClientAuthOptions
127+
#else
128+
((DnsEndPoint)_endpoint).Host
129+
#endif
130+
);
126131
}
127132
else
128133
{
129134
_inputStream = new NetworkStream(_socket);
130135
}
131-
#else
132-
_inputStream = new NetworkStream(_socket);
133-
#endif
134136
}
135137
else
136138
{
@@ -182,19 +184,21 @@ public async Task ConnectAsync()
182184

183185
if (success)
184186
{
185-
#if NET5_0_OR_GREATER
186187
if (_useSslStream)
187188
{
188189
_sslStream = new SslStream(new NetworkStream(_socket));
189-
await _sslStream.AuthenticateAsClientAsync(_sslClientAuthOptions);
190+
await _sslStream.AuthenticateAsClientAsync(
191+
#if NET5_0_OR_GREATER
192+
_sslClientAuthOptions
193+
#else
194+
((DnsEndPoint)_endpoint).Host
195+
#endif
196+
);
190197
}
191198
else
192199
{
193200
_inputStream = new NetworkStream(_socket);
194201
}
195-
#else
196-
_inputStream = new NetworkStream(_socket);
197-
#endif
198202
}
199203
else
200204
{

0 commit comments

Comments
 (0)