Skip to content

Instantly share code, notes, and snippets.

@sanmai
Last active December 1, 2020 13:14
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sanmai/98666f96294d05c64172 to your computer and use it in GitHub Desktop.
Save sanmai/98666f96294d05c64172 to your computer and use it in GitHub Desktop.
Dumps the whole certificate chain for a server in purposes of OCSP stapling
#!/usr/bin/perl
use strict;
use warnings;
# install libio-socket-ssl-perl to get this
use IO::Socket::SSL;
my $hostname = shift or die "Usage: $0 www.example.com\n";
IO::Socket::SSL->new(
PeerHost => "$hostname:443",
SSL_verify_callback => sub {
my $cert = $_[4];
my $subject = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert));
print "# $subject\n";
print Net::SSLeay::PEM_get_string_X509($cert),"\n";
return 1;
}
) or die $SSL_ERROR||$!;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment