diff options
author | Patrick Spek <p.spek@tyil.nl> | 2021-11-10 10:51:52 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2021-11-10 11:00:25 +0100 |
commit | 5aaf09eb8f7a007dbd2ddeb31dafc106491d5c0a (patch) | |
tree | 2ab9e2a58e5259eb6bfa4974624cc44d8e926427 | |
parent | 4d30d355993646dcf9a87b5c0b7c4ca1874978d5 (diff) |
Add new utility to retrieve a certificate by index out of a larger chain
-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++; + } +} |