-
Notifications
You must be signed in to change notification settings - Fork 9
/
cert-split.pl
42 lines (34 loc) · 877 Bytes
/
cert-split.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
#
# Splits a certficate file with multiple entries up into
# one certificate perl file
#
# Artistic License
#
# v0.0.1 Nick Burch <[email protected]>
#
my $filename = shift;
unless($filename) {
die("Usage:\n cert-split.pl <certificate-file>\n");
}
open INP, "<$filename" or die("Unable to load \"$filename\"\n");
my $ifile = "";
my $thisfile = "";
while(<INP>) {
$ifile .= $_;
$thisfile .= $_;
if($_ =~ /^\-+END(\s\w+)?\sCERTIFICATE\-+$/) {
print "Found a complete certificate:\n";
print `echo "$thisfile" | openssl x509 -noout -issuer -subject`;
print "\n";
print "What file should this be saved to?\n";
my $fname = <>;
open CERT, ">$fname";
print CERT $thisfile;
close CERT;
$thisfile = "";
print "Certificate saved\n\n";
}
}
close INP;
print "Completed\n";