DEV Community

James Moberg
James Moberg

Posted on

3 1

Identify SSL Expiration Date using ColdFusion

We use LetsEncrypt and monitor the SSL certificate expiration dates locally by parsing the actual certificate files, but if you require a way to remotely monitor a third-party SSL certificate in order to ensure that the renewal process hasn't failed, here’s some #cfml / #java to do just that.

Source

<!--- 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()>

Top comments (3)

Collapse
 
dineshrathee12 profile image
Dinesh Rathee

LetsEncrypt have revoked around 3 million certs last night due to a bug that they found. Are you impacted by this, Check out ?

DevTo
[+] dev.to/dineshrathee12/letsencrypt-...

GitHub
[+] github.com/dineshrathee12/Let-s-En...

LetsEncryptCommunity
[+] community.letsencrypt.org/t/letsen...

Collapse
 
gamesover profile image
James Moberg

No, we weren't impacted by it. I immediately forwarded a tweet regarding it to my business partner and we currently aren't generating the types of certs that are affected.

Collapse
 
dineshrathee12 profile image
Dinesh Rathee

Nice one :)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay