Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CacheCredential()

static void System.Net.Security.SslSessionsCache.CacheCredential ( SafeFreeCredentials creds,
byte[] thumbPrint,
SslProtocols sslProtocols,
bool isServer,
EncryptionPolicy encryptionPolicy )
inlinestaticpackage

Definition at line 130 of file SslSessionsCache.cs.

131 {
132 if (creds.IsInvalid)
133 {
134 if (System.Net.NetEventSource.Log.IsEnabled())
135 {
136 System.Net.NetEventSource.Info(null, $"Refused to cache an Invalid Handle {creds}, Current Cache Count = {s_cachedCreds.Count}", "CacheCredential");
137 }
138 return;
139 }
140 SslCredKey key = new SslCredKey(thumbPrint, (int)sslProtocols, isServer, encryptionPolicy);
141 SafeFreeCredentials cachedCredential = GetCachedCredential(key);
142 if (cachedCredential == null || cachedCredential.IsClosed || cachedCredential.IsInvalid)
143 {
145 {
147 if (cachedCredential == null || cachedCredential.IsClosed || cachedCredential.IsInvalid)
148 {
149 SafeCredentialReference safeCredentialReference = SafeCredentialReference.CreateReference(creds);
150 if (safeCredentialReference != null)
151 {
153 if (System.Net.NetEventSource.Log.IsEnabled())
154 {
155 System.Net.NetEventSource.Info(null, $"Caching New Handle = {creds}, Current Cache Count = {s_cachedCreds.Count}", "CacheCredential");
156 }
158 }
159 }
160 else if (System.Net.NetEventSource.Log.IsEnabled())
161 {
162 System.Net.NetEventSource.Info(null, $"CacheCredential() (locked retry) Found already cached Handle = {cachedCredential}", "CacheCredential");
163 }
164 return;
165 }
166 }
167 if (System.Net.NetEventSource.Log.IsEnabled())
168 {
169 System.Net.NetEventSource.Info(null, $"CacheCredential() Ignoring incoming handle = {creds} since found already cached Handle = {cachedCredential}", "CacheCredential");
170 }
171 static void ShrinkCredentialCache()
172 {
173 if (s_cachedCreds.Count % 32 == 0)
174 {
176 for (int i = 0; i < array.Length; i++)
177 {
178 SafeCredentialReference value = array[i].Value;
179 SafeFreeCredentials target = value.Target;
180 SafeCredentialReference value2;
181 if (target == null)
182 {
183 s_cachedCreds.TryRemove(array[i].Key, out value2);
184 }
185 else
186 {
187 value.Dispose();
188 value = SafeCredentialReference.CreateReference(target);
189 if (value != null)
190 {
191 s_cachedCreds[array[i].Key] = value;
192 }
193 else
194 {
195 s_cachedCreds.TryRemove(array[i].Key, out value2);
196 }
197 }
198 }
199 if (System.Net.NetEventSource.Log.IsEnabled())
200 {
201 System.Net.NetEventSource.Info(null, $"Scavenged cache, New Cache Count = {s_cachedCreds.Count}", "CacheCredential");
202 }
203 }
204 }
205 }
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static readonly ConcurrentDictionary< SslCredKey, SafeCredentialReference > s_cachedCreds
static SafeFreeCredentials GetCachedCredential(SslCredKey key)

References System.array, System.Net.Security.SafeCredentialReference.CreateReference(), System.Net.Security.SslSessionsCache.GetCachedCredential(), System.Net.NetEventSource.Info(), System.key, System.Net.NetEventSource.Log, System.Net.Security.SslSessionsCache.s_cachedCreds, and System.value.

Referenced by System.Net.Security.SecureChannel.GenerateToken().