Skip navigation
mischa.suemnig
Currently Being Moderated

Get remote servers SSL expiration date

Feb 7, 2012 3:15 PM

Tags: #ssl_certificate_expiration_date #remote_server_ssl #cfhttp

We have many clients that all have multiple web sites.  The majority of the web sites, we do not host.  If I wanted to look up when their SSL certificate was going to expire and proactively notify them, does anyone know any way to do this through CF9?

 

I've done the following, but I don't get the information from the header that I'm looking for:

<cfhttp url="https://www.amazon.com" result="out"></cfhttp>

 

<cfdump var="#out#" />

 

However, in PHP, I simply set the following options before calling curl:

curl_setopt($ch[$i], CURLOPT_VERBOSE, true);

curl_setopt($ch[$i], CURLOPT_CERTINFO, true);

 

VERBOSE enables more info

CERTINFO enables the certificate information to pass in the header

 

then curl_getinfo() on my curl handler and it's in an array.

 

I ended up using PHP for this task, but it seems there ought to be a way to do it in CF.

 

Thanks for any thoughts anyone might have!

 
Replies
  • Currently Being Moderated
    Feb 28, 2012 10:49 AM   in reply to mischa.suemnig

    Sure you can do this in CF using Java:

     

    <cfset factory = CreateObject("java", "javax.net.ssl.HttpsURLConnection").getDefaultSSLSocketFactory()>

    <cfset socket = factory.createSocket("foundeo.com", 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>#cert.getSubjectDN().getName()# - Valid Until #DateFormat(cert.getNotAfter())#</cfoutput><br />

      </cfloop> 

    </cfif>

    <cfset socket.close()>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points