diff options
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/ssln | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/.local/bin/ssln b/.local/bin/ssln new file mode 100755 index 0000000..546107d --- /dev/null +++ b/.local/bin/ssln @@ -0,0 +1,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++; + } +} |