} // End Sub CertificateFileChanged public static System.Security.Cryptography.X509Certificates.X509Certificate2 ServerCertificateSelector( System.Collections.Concurrent.ConcurrentDictionary <string, CertHackStore> certs , Microsoft.AspNetCore.Connections.ConnectionContext connectionContext , string name) { if (certs != null && certs.Count > 0) { // return certs.GetEnumerator().Current.Value; // return System.Linq.Enumerable.FirstOrDefault(certs); foreach (System.Collections.Generic.KeyValuePair <string, CertHackStore> thisCert in certs) { System.Console.WriteLine("SNI Name: {0}", name); return(thisCert.Value.Certificate); } // Next thisCert } // End if (certs != null && certs.Count > 0) // CertHackStore cert; // if (name != null && certs.TryGetValue(name, out cert)) // { // return cert.NewCertificate; // } throw new System.IO.InvalidDataException("No certificate for name \"" + name + "\"."); } // End Function ServerCertificateSelector