#!/usr/bin/perl # script for splitting multi-cert input into individual certs # Artistic Licence # # v0.0.1 Nick Burch # v0.0.2 Tom Yates # v0.0.3 Matthew Buckett # 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() { $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;