use strict; use warnings; use Net::SSLeay qw(die_now die_if_ssl_error); Net::SSLeay::load_error_strings(); Net::SSLeay::SSLeay_add_ssl_algorithms(); # Important! Net::SSLeay::randomize(); my $cert_path = '/path/to/cert.pem'; my $key_path = '/path/to/notacakeynopass.pem'; my $ctx = Net::SSLeay::new_x_ctx() or die("Failed to create CTX $!"); Net::SSLeay::set_cert_and_key($ctx, $cert_path, $key_path); my $ssl = Net::SSLeay::new($ctx) or die("Failed to create SSL $!"); my $cert = Net::SSLeay::dump_peer_certificate($ssl); ## Presumably, the expiration will be in here somewhere print "Cert is ", length($cert), "bytes\n"; print $cert, "\n";