-
Notifications
You must be signed in to change notification settings - Fork 55
Working with SSL Certificates
Itay Sagui edited this page Mar 17, 2015
·
1 revision
In order to work with SSL Certificates, a certificate validation method should be provided to the ServicePointManager
:
private static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
Console.WriteLine("Issued by: " + certificate.Issuer);
Console.WriteLine("Issued to: " + certificate.Subject);
Console.WriteLine("Valid until: " + certificate.GetExpirationDateString());
if (sslPolicyErrors == SslPolicyErrors.None)
Console.WriteLine("Valid server certificate");
return true;
}
And then somewhere in your code initialization:
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);