Created
January 6, 2017 04:33
-
-
Save code-atom/e20657e8a398fd0dd679d1731e6200ba to your computer and use it in GitHub Desktop.
Check when SSL get expire.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mail.google.com"); | |
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); | |
response.Close(); | |
//retrieve the ssl cert and assign it to an X509Certificate object | |
X509Certificate cert = request.ServicePoint.Certificate; | |
//convert the X509Certificate to an X509Certificate2 object by passing it into the constructor | |
X509Certificate2 cert2 = new X509Certificate2(cert); | |
string cn = cert2.GetIssuerName(); | |
string cedate = cert2.GetExpirationDateString(); | |
string cpub = cert2.GetPublicKeyString(); | |
Console.WriteLine(cert2.GetExpirationDateString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment