Skip to content

Instantly share code, notes, and snippets.

@ericlaw1979
Last active March 26, 2021 12:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ericlaw1979/678ed408075da213f742 to your computer and use it in GitHub Desktop.
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
// 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