private void LogCertificateValidation(RemoteCertValidationCallback remoteCertValidationCallback, SslPolicyErrors sslPolicyErrors, bool success, X509Chain chain)
{
if (!NetEventSource.IsEnabled) return;
if (sslPolicyErrors != SslPolicyErrors.None)
{
NetEventSource.Log.RemoteCertificateError(this, SR.net_log_remote_cert_has_errors);
if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) != 0)
{
NetEventSource.Log.RemoteCertificateError(this, SR.net_log_remote_cert_not_available);
}
if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNameMismatch) != 0)
{
NetEventSource.Log.RemoteCertificateError(this, SR.net_log_remote_cert_name_mismatch);
}
if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) != 0)
{
string chainStatusString = "ChainStatus: ";
foreach (X509ChainStatus chainStatus in chain.ChainStatus)
{
chainStatusString += "\t" + chainStatus.StatusInformation;
}
NetEventSource.Log.RemoteCertificateError(this, chainStatusString);
}
}
if (success)
{
if (remoteCertValidationCallback != null)
{
NetEventSource.Log.RemoteCertDeclaredValid(this);
}
else
{
NetEventSource.Log.RemoteCertHasNoErrors(this);
}
}
else
{
if (remoteCertValidationCallback != null)
{
NetEventSource.Log.RemoteCertUserDeclaredInvalid(this);
}
}
}
}