How to find the SSL certificate's expiration.

P

perlnovice

Hello all,

I would like to write a script running on a client to determine the
expiration date of a web server's SSL certificate. But I do not know
how to. Can anybody give me a hint.

Thanks in advance for your information.

Tuan
 
L

lostriver

I would like to write a script running on a client to determine the
expiration date of a web server's SSL certificate. But I do not know
how to. Can anybody give me a hint.

One way to do it is to use Net::SSLeay module available from CPAN.


#!/usr/local/bin/perl
use Net::SSLeay;

$site = shift || die "Usage: $0 URL\n";
(undef, undef, undef, $server_cert) = &Net::SSLeay::get_https3($site, 443, '/');

if ( defined ($server_cert) ) {
$from = Net::SSLeay::X509_get_notBefore($server_cert);
print Net::SSLeay::p_ASN1_UTCTIME_put2string($from), "\n";

$to = Net::SSLeay::X509_get_notAfter($server_cert);
print Net::SSLeay::p_ASN1_UTCTIME_put2string($to);
}
__END__
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top