-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcert-show-all
executable file
·62 lines (49 loc) · 1.03 KB
/
cert-show-all
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl
sub help {
print <<'EOHELP';
usage: cert-show-all [--debug] [certificates.crt]
cert-show-all --help
print all certificates contained in certificates.crt chain
--debug include original encoded certificates in printout
EOHELP
}
sub println {
print $_[0]."\n";
}
use strict;
use warnings;
my $cert_no=1;
my $current_cert="";
my $DEBUG=0;
if( $#ARGV >= 0 ) {
if( $ARGV[0] eq "--help" ) {
help();
exit();
}
elsif( $ARGV[0] eq "--debug" ) {
$DEBUG=1;
shift @ARGV;
}
}
while( <> ) {
my $line = $_;
$current_cert .= $line;
if( $line =~ /-----END CERTIFICATE-----/ ) {
# print out current certificate
#
println();
println("=======================");
println("Certificate: ".$cert_no);
println("=======================");
println();
#
print $current_cert if $DEBUG;
#
open( OPENSSL, "|openssl x509 -noout -text" );
print OPENSSL $current_cert;
close OPENSSL;
# perpare next cert
$current_cert = "";
$cert_no++;
}
}