diff options
author | Rob Austein <sra@hactrn.net> | 2006-08-22 22:26:54 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2006-08-22 22:26:54 +0000 |
commit | 9ed488202aab1dac7754afda9d155fcd8fc20943 (patch) | |
tree | 4b63944213d8c63d409c739379e694682cc9b581 /scripts/gki.pl | |
parent | 638a2b15b32f796c76526dcd4c0cf4ea851e84fa (diff) |
# on 2006/08/09 15:57:05, sra did:
.
svn path=/scripts/gki.pl; revision=181
Diffstat (limited to 'scripts/gki.pl')
-rw-r--r-- | scripts/gki.pl | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/scripts/gki.pl b/scripts/gki.pl index 5e9f42e8..a9e93748 100644 --- a/scripts/gki.pl +++ b/scripts/gki.pl @@ -1,32 +1,35 @@ -#!/usr/local/bin/perl -eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' - if $running_under_some_shell; - # this emulates #! processing on NIH machines. - # (remove #! line above if indigestible) +: +eval 'exec perl -S $0 ${1+"$@"}' + if 0; -eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift; - # process any FOO=bar switches +use MIME::Base64; -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator +my $openssl = "/u/sra/isc/route-pki/subvert-rpki.hactrn.net/openssl/trunk/apps/openssl"; -while (<>) { - chomp; # strip record separator - if (/X509v3 Subject Key Identifier:/) { - $ski = $. + 1; - } - if (/X509v3 Authority Key Identifier:/) { - $aki = $. + 1; - } - if ($ski && $. == $ski) { - s/^[ ]*//; - $S = $_; - } - if ($aki && $. == $aki) { - s/^[ ]*keyid://; - $a = $_; - } +sub g { + my $x = shift; + $x =~ s{:}{}g; + $x = pack("H*", $x); + $x = encode_base64($x, ""); + $x =~ y{+/}{-_}; + $x =~ s{=+$}{}; + return $x; } -print $S, $a, $f; - +while (@ARGV) { + my $f = shift(@ARGV); + open(F, "-|", $openssl, qw(x509 -noout -inform DER -text -in), $f) + or die("Couldn't run openssl x509 on $f: $!\n"); + while (<F>) { + chomp; + if (/X509v3 Authority Key Identifier:/) { + $aki = $. + 1; + } + if ($aki && $. == $aki) { + s/^[ \t]*keyid://; + $a = $_; + } + } + close(F); + print(g($a), " $f\n"); +} |