blob: 546107dd423f3a31fc55f71504e06ddd3412f3c4 (
plain)
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
|
#!/usr/bin/env perl
use strict;
use utf8;
use warnings;
my $cert = "";
my $count = 0;
# Loop over STDIN to get the nth certificate
while (<STDIN>) {
# Append current line to potential cert
$cert .= $_;
# Check for end of certificate
if ($_ =~ /^\-+END(\s\w+)?\sCERTIFICATE\-+$/) {
# Print out the cert if this is the index we're looking for
if (grep(/^$count$/, @ARGV)) {
print $cert;
}
# Reset potential cert
$cert = "";
$count++;
}
}
|