Created
August 23, 2010 13:33
-
-
Save mschmitt/545485 to your computer and use it in GitHub Desktop.
Trying to figure out how to extract certificate from SSL session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use diagnostics; | |
use Data::Dumper; | |
use IO::Socket::INET; | |
use Net::SSLeay::OO; | |
use Net::SSLeay::OO::X509; | |
use Net::SSLeay::OO::Constants qw(OP_ALL); | |
my $sslctx = Net::SSLeay::OO::Context->new; | |
$sslctx->set_options(OP_ALL); | |
my $client = IO::Socket::INET->new('www.google.com:443') | |
or die "FAIL: $!"; | |
my $sslclient = Net::SSLeay::OO::SSL->new(ctx => $sslctx); | |
$sslclient->set_fd($client); | |
$sslclient->connect; | |
my $cert = $sslclient->get_peer_certificate; | |
# Shows the certificate subject | |
print $cert->get_subject_name->oneline . "\n"; | |
print Dumper($cert); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment