Retrieve SSL certificate information

I recently had a need to retrieve SSL certificate information from a group of servers, running a mix of both Linux and Windows, and I didn’t really want to get the information manually.

The web applications running on these servers where a mix of “regular” web applications and applications without any front-end. Also many of them where running on shared hosts.

My first idea was to write a script that performed an HTTP web request to get the certificate object. This worked for some of the applications, but not all. So wrote another script that used TCP instead. Both of these scripts where written in PowerShell, but for good measure I wrote a small bash script as well that I had planned to use on the Linux machines.

But in the end the two PowerShell scripts seemed to be good enough for the task at hand. I’m sharing my scripts here in case they can be of use to others in a similar situation.

The usage should be easy enough, though note that Get-CertInfoHttp takes the input as a URL while Get-CertInfoTcp takes a computer name.

All three scripts should fetch the same kind of data, but feel free to customize them to your own needs. I actually ended up writing a wrapper script that first tried to get the SSL info using HTTP and then to fall back to try using TCP if that failed. This worked pretty well in my case.

Enjoy. Let me know if you have any questions of comments about the scripts.


    1. For applications not running HTTP (we have some APIs for instance) and others with authentication to access, I had to use TCP instead.


Leave a Reply to Øyvind Kallstad Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s