Last active
March 2, 2020 01:25
-
-
Save JamoCA/6aff53c0e002df8faa8c316f0138c507 to your computer and use it in GitHub Desktop.
Samples ColdFusion script to retrieve SSL certificate data to determine expiration date
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
<!--- 20190419 | |
BLOG: https://dev.to/gamesover/identify-ssl-expiration-date-using-coldfusion-1lm5 ---> | |
<cfset HostToTest = "letsencrypt.org"> | |
<cfset factory = CreateObject("java", "javax.net.ssl.HttpsURLConnection").getDefaultSSLSocketFactory()> | |
<cfset socket = factory.createSocket(HostToTest, JavaCast("int",443))> | |
<cfset socket.startHandshake()> | |
<cfset certs = socket.getSession().getPeerCertificates()> | |
<cfif IsArray(certs)> | |
<cfloop from="1" to="#ArrayLen(certs)#" index="i"> | |
<cfset cert = certs[i]> | |
<cfoutput> | |
<div>#cert.getSubjectDN().getName()# - Valid Until <b>#DateFormat(cert.getNotAfter())#</b></div> | |
</cfoutput> | |
</cfloop> | |
</cfif> | |
<cfset socket.close()> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment