简体   繁体   中英

Get entire certificate using Perl's Net::SSLeay

I want to use the Perl library Net::SSLeay to download a server's SSL certificate but am having trouble figuring out how to do this. I want the entire certificate, not just the common name and a few of the fields.

For example, I would give the script the argument google.com and it would connect to https://google.com and get the entire certificate string for the certificate with CN "*.google.com".

This script needs to run on a Debian wheezy server so must use version 1.48 of Net::SSLeay .

I believe this might be what you want?

($reply, $err, $cert) = sslcat('www.google.com', 443, '/'); # 5
$PEM = Net::SSLeay::PEM_get_string_X509( $cert);

Will give you the PEM encoded SSL certificate. You can decode it using MIME::Base64.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM