Overview
This is a simple little gem for checking when an SSL will expire.
Installation
Add this line to your application's Gemfile:
gem 'ssl_expiry'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ssl_expiry
Usage
Simple Usage
require 'ssl_expiry'
SSLExpiry::SSLExpiry.check_certificates('wolfsoftware.com')
Results:
{"wolfsoftware.com"=>{"status"=>200, "expires_on"=>"02 Aug 2024", "expires_in"=>57, "common_name"=>"wolfsoftware.com", "issuer"=>"Let's Encrypt"}}
Multiple Domains
It is possible to check a list of domains rather than just single domains, this is done by passing a list[] to SSLExpiry::SSLExpiry.check_certificates.
require 'ssl_expiry'
SSLExpiry::SSLExpiry.check_certificates(['wolfsoftware.com', 'wolfsoftware.net'])
Displaying the output
require 'ssl_expiry'
results = SSLExpiry::SSLExpiry.check_certificates('wolfsoftware.com')
SSLExpiry::SSLExpiry.display_results(results)
This would give the following output
----------------------------------------------------------------------------------------------------
Domain | Status
----------------------------------------------------------------------------------------------------
wolfsoftware.com | expires on 02 Aug 2024 (in 57 days) [CN=wolfsoftware.com]
----------------------------------------------------------------------------------------------------
Command Line Tools
There is a command line tool included with this gem.
check-ssl -d wolfsoftware.com
----------------------------------------------------------------------------------------------------
Domain | Status
----------------------------------------------------------------------------------------------------
wolfsoftware.com | expires on 02 Aug 2024 (in 57 days) [CN=wolfsoftware.com]
----------------------------------------------------------------------------------------------------
Multiple Domains
To check multiple domains at the same time, simply supply a comma separated list.
check-ssl -d wolfsoftware.com,wolfsoftware.net
------------------------------------------------------------------------------------------------------------------------
Domain | Status
------------------------------------------------------------------------------------------------------------------------
wolfsoftware.com | expires on 02 Aug 2024 (in 57 days) [CN=wolfsoftware.com]
wolfsoftware.net | expires on 02 Aug 2024 (in 57 days) [CN=wolfsoftware.net]
------------------------------------------------------------------------------------------------------------------------
Custom port
If you want to check an SSL expiry on a custom port you can do this by adding the port to the end of the domain.
check-ssl -d wolfsoftware.com:8080