Created
July 22, 2015 14:03
-
-
Save buckett/cc3ceca23a43beab2b71 to your computer and use it in GitHub Desktop.
Show all the certificates in a certificate chains file.
This file contains 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 | |
# script for splitting multi-cert input into individual certs | |
# Artistic Licence | |
# | |
# v0.0.1 Nick Burch <[email protected]> | |
# v0.0.2 Tom Yates <[email protected]> | |
# v0.0.3 Matthew Buckett <[email protected]> | |
# | |
use strict; | |
use warnings; | |
my $filename = shift; | |
unless($filename) { | |
die("You must specify a cert file.\n"); | |
} | |
open INP, "<$filename" or die("Unable to load \"$filename\"\n"); | |
my $thisfile = ""; | |
while(<INP>) { | |
$thisfile .= $_; | |
# Some certs have had trailing whitespace after the ---- so we're relaxed about this. | |
if($_ =~ /^-+END(\s\w+)?\sCERTIFICATE-+/) { | |
print "Found a complete certificate:\n"; | |
print `echo "$thisfile" | openssl x509 -noout -text`; | |
$thisfile = ""; | |
} | |
} | |
close INP; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment