@@ -160,7 +160,6 @@ internal static SafeSslContextHandle GetOrCreateSslContextHandle(SslAuthenticati
160
160
if ( sslAuthenticationOptions . IsClient )
161
161
{
162
162
var key = new SslContextCacheKey ( protocols , sslAuthenticationOptions . CertificateContext ? . TargetCertificate . GetCertHash ( HashAlgorithmName . SHA256 ) ) ;
163
-
164
163
return s_clientSslContexts . GetOrCreate ( key , static ( args ) =>
165
164
{
166
165
var ( sslAuthOptions , protocols , allowCached ) = args ;
@@ -173,14 +172,13 @@ internal static SafeSslContextHandle GetOrCreateSslContextHandle(SslAuthenticati
173
172
174
173
bool hasAlpn = sslAuthenticationOptions . ApplicationProtocols != null && sslAuthenticationOptions . ApplicationProtocols . Count != 0 ;
175
174
176
- SafeSslContextHandle ? handle = AllocateSslContext ( sslAuthenticationOptions , protocols , allowCached ) ;
177
-
178
- if ( ! sslAuthenticationOptions . CertificateContext ! . SslContexts ! . TryGetValue ( protocols | ( hasAlpn ? FakeAlpnSslProtocol : SslProtocols . None ) , out handle ) )
175
+ SslProtocols serverCacheKey = protocols | ( hasAlpn ? FakeAlpnSslProtocol : SslProtocols . None ) ;
176
+ if ( ! sslAuthenticationOptions . CertificateContext ! . SslContexts ! . TryGetValue ( serverCacheKey , out SafeSslContextHandle ? handle ) )
179
177
{
180
178
// not found in cache, create and insert
181
179
handle = AllocateSslContext ( sslAuthenticationOptions , protocols , allowCached ) ;
182
180
183
- SafeSslContextHandle cached = sslAuthenticationOptions . CertificateContext ! . SslContexts ! . GetOrAdd ( protocols | ( hasAlpn ? FakeAlpnSslProtocol : SslProtocols . None ) , handle ) ;
181
+ SafeSslContextHandle cached = sslAuthenticationOptions . CertificateContext ! . SslContexts ! . GetOrAdd ( serverCacheKey , handle ) ;
184
182
185
183
if ( handle != cached )
186
184
{
0 commit comments