diff options
author | Rob Austein <sra@hactrn.net> | 2006-08-22 22:28:36 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2006-08-22 22:28:36 +0000 |
commit | ae410a8b815a014cbdd8af95cae6e6efe2d15ac8 (patch) | |
tree | 450fd19e7b84733b571eed8a785f9234fb908ccd /scripts | |
parent | 16cae687d82b8f0d6c57df398dc0d31463ac099b (diff) |
# on 2006/08/10 06:42:14, sra did:
Initial revision
svn path=/scripts/uri.pl; revision=196
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/uri.pl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/uri.pl b/scripts/uri.pl new file mode 100644 index 00000000..e91c4abe --- /dev/null +++ b/scripts/uri.pl @@ -0,0 +1,46 @@ +: +# $Id$ +eval 'exec perl -w -S $0 ${1+"$@"}' + if 0; + +use MIME::Base64; + +sub g { + my $x = shift; + $x =~ s{:}{}g; + $x = pack("H*", $x); + $x = encode_base64($x, ""); + $x =~ y{+/}{-_}; + $x =~ s{=+$}{}; + return $x; +} + +while (@ARGV) { + my ($file, $aki, $ski, $a, $s) = shift(@ARGV); + if ($file =~ /\.cer$/) { + open(F, "-|", qw(openssl x509 -noout -inform DER -text -in), $file) + or die("Couldn't run openssl x509 on $file: $!\n"); + } elsif ($file =~ /\.crl$/) { + open(F, "-|", qw(openssl crl -noout -inform DER -text -in), $file) + or die("Couldn't run openssl x509 on $file: $!\n"); + } else { + next; + } + while (<F>) { + chomp; + s/^\s*//; + s/^keyid://; + $a = $. + 1 + if (/X509v3 Authority Key Identifier:/); + $s = $. + 1 + if (/X509v3 Subject Key Identifier:/); + $aki = $_ + if ($a && $. == $a); + $ski = $_ + if ($s && $. == $s); + } + close(F); + my $gaki = $aki ? g($aki) : "=" x 27; + my $gski = $ski ? g($ski) : "=" x 27; + print("$gaki $gski $file\n"); +} |