From 5aaf09eb8f7a007dbd2ddeb31dafc106491d5c0a Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 10 Nov 2021 10:51:52 +0100 Subject: Add new utility to retrieve a certificate by index out of a larger chain --- .local/bin/ssln | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 .local/bin/ssln 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 () { + # 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++; + } +} -- cgit v1.1