#!/usr/bin/perl use strict; use warnings; use File::Temp qw(tempfile); use OpenSSL::Cmd; use IPC::Run; my($cert) = openssl s_client -connect myhost.com:443; my($tmpfh,$tempfile) = tempfile(DIR=>'/tmp',UNLINK=>1); croak "Failed to open temp file:$!" unless( defined($tmpfh) ); $tmpfh->print( $cert ); $tmpfh->close; my($enddate) = openssl x509 -enddate -noout -in $tempfile; ($enddate)=~s{notAfter=}{}; print "Certificate expires on :", $enddate; exit;