|
7 | 7 | using System.Collections.ObjectModel;
|
8 | 8 | using System.Security.Authentication;
|
9 | 9 | using System.Net.Security;
|
| 10 | +using System.Runtime.InteropServices; |
10 | 11 | using System.Security.Cryptography.X509Certificates;
|
11 | 12 | using System.Threading;
|
12 | 13 | using Microsoft.Quic;
|
@@ -39,13 +40,13 @@ private static bool GetConfigurationCacheEnabled()
|
39 | 40 |
|
40 | 41 | private static readonly ConcurrentDictionary<CacheKey, MsQuicConfigurationSafeHandle> s_configurationCache = new();
|
41 | 42 |
|
42 |
| - private readonly struct CacheKey : IEquatable<CacheKey> |
| 43 | + private struct CacheKey : IEquatable<CacheKey> |
43 | 44 | {
|
44 |
| - public readonly List<byte[]> CertificateThumbprints; |
45 |
| - public readonly QUIC_CREDENTIAL_FLAGS Flags; |
46 |
| - public readonly QUIC_SETTINGS Settings; |
47 |
| - public readonly List<SslApplicationProtocol> ApplicationProtocols; |
48 |
| - public readonly QUIC_ALLOWED_CIPHER_SUITE_FLAGS AllowedCipherSuites; |
| 45 | + private readonly List<byte[]> CertificateThumbprints; |
| 46 | + private readonly QUIC_CREDENTIAL_FLAGS Flags; |
| 47 | + private QUIC_SETTINGS Settings; // not readonly to be able to compare using MemoryMarshal |
| 48 | + private readonly List<SslApplicationProtocol> ApplicationProtocols; |
| 49 | + private readonly QUIC_ALLOWED_CIPHER_SUITE_FLAGS AllowedCipherSuites; |
49 | 50 |
|
50 | 51 | public CacheKey(QUIC_SETTINGS settings, QUIC_CREDENTIAL_FLAGS flags, X509Certificate? certificate, ReadOnlyCollection<X509Certificate2>? intermediates, List<SslApplicationProtocol> alpnProtocols, QUIC_ALLOWED_CIPHER_SUITE_FLAGS allowedCipherSuites)
|
51 | 52 | {
|
@@ -98,7 +99,7 @@ public bool Equals(CacheKey other)
|
98 | 99 |
|
99 | 100 | return
|
100 | 101 | Flags == other.Flags &&
|
101 |
| - Settings.Equals(other.Settings) && |
| 102 | + MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref Settings, 1)).SequenceEqual(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref other.Settings, 1))) && |
102 | 103 | AllowedCipherSuites == other.AllowedCipherSuites;
|
103 | 104 | }
|
104 | 105 |
|
|
0 commit comments