private bool AcquireServerCredentials(ref byte[] thumbPrint)
{
X509Certificate serverCertificate = null;
if (this.m_CertSelectionDelegate != null)
{
X509CertificateCollection localCertificates = new X509CertificateCollection();
localCertificates.Add(this.m_ServerCertificate);
serverCertificate = this.m_CertSelectionDelegate(string.Empty, localCertificates, null, new string[0]);
}
else
{
serverCertificate = this.m_ServerCertificate;
}
if (serverCertificate == null)
{
throw new NotSupportedException(SR.GetString("net_ssl_io_no_server_cert"));
}
X509Certificate2 certificate2 = this.EnsurePrivateKey(serverCertificate);
if (certificate2 == null)
{
throw new NotSupportedException(SR.GetString("net_ssl_io_no_server_cert"));
}
byte[] certHash = certificate2.GetCertHash();
try
{
SafeFreeCredentials credentials = SslSessionsCache.TryCachedCredential(certHash, this.m_ProtocolFlags, this.m_EncryptionPolicy);
if (credentials != null)
{
this.m_CredentialsHandle = credentials;
this.m_ServerCertificate = serverCertificate;
return(true);
}
SecureCredential secureCredential = new SecureCredential(4, certificate2, SecureCredential.Flags.Zero, this.m_ProtocolFlags, this.m_EncryptionPolicy);
this.m_CredentialsHandle = this.AcquireCredentialsHandle(CredentialUse.Inbound, ref secureCredential);
thumbPrint = certHash;
this.m_ServerCertificate = serverCertificate;
}
finally
{
if (serverCertificate != certificate2)
{
certificate2.Reset();
}
}
return(false);
}