Last active
March 26, 2021 12:40
-
-
Save ericlaw1979/678ed408075da213f742 to your computer and use it in GitHub Desktop.
This FiddlerScript highlights in red Sessions secured by certificates that will expire in the next 30 days
This file contains 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
// Inside Rules > Customize Rules > OnBoot, add the following line: | |
FiddlerApplication.add_OnValidateServerCertificate(onEvalCert); | |
// Just before that function, add the following new function: | |
static function onEvalCert(o: Object, e: ValidateServerCertificateEventArgs) | |
{ | |
try | |
{ | |
var X2: System.Security.Cryptography.X509Certificates.X509Certificate2 = | |
new System.Security.Cryptography.X509Certificates.X509Certificate2(e.ServerCertificate); | |
// Cert expires in next 30 days | |
if (DateTime.UtcNow.AddDays(30) > X2.NotAfter) | |
{ | |
if (DateTime.UtcNow.AddDays(5) > X2.NotAfter) | |
{ | |
FiddlerApplication.AlertUser("Certificate Expiring!", | |
"The certificate for " + e.Session.hostname + " is expiring " + X2.NotAfter.ToShortDateString() + "!"); | |
} | |
e.Session["ui-backcolor"] = "red"; | |
e.Session["ui-Comments"] = "Cert Expires:" + e.ServerCertificate.GetExpirationDateString(); | |
e.Session.RefreshUI(); | |
} | |
} | |
catch (ex) | |
{ | |
FiddlerApplication.Log.LogFormat("Failed to evaluate certificate: {0}", ex.Message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment