X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=stage5%2Fmisc%2Fcertdata%2Fmake-cert.pl;fp=stage5%2Fmisc%2Fcertdata%2Fmake-cert.pl;h=60b6fea823eca89b45305dcd493818d20bcdc20f;hb=0a06f07a9134afb9018e5a8922b475d0d39aebc4;hp=0000000000000000000000000000000000000000;hpb=64a7c6b49c947928a715c1b74e9511307de7061c;p=hvlinux.git diff --git a/stage5/misc/certdata/make-cert.pl b/stage5/misc/certdata/make-cert.pl new file mode 100755 index 0000000..60b6fea --- /dev/null +++ b/stage5/misc/certdata/make-cert.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +# Used to generate PEM encoded files from Mozilla certdata.txt. +# Run as ./make-cert.pl > certificate.crt +# +# Parts of this script courtesy of RedHat (mkcabundle.pl) +# +# This script modified for use with single file data (tempfile.cer) extracted +# from certdata.txt, taken from the latest version in the Mozilla NSS source. +# mozilla/security/nss/lib/ckfw/builtins/certdata.txt +# +# Authors: DJ Lucas +# Bruce Dubbs +# +# Version 20120211 + +my $certdata = './tempfile.cer'; + +open( IN, "cat $certdata|" ) + || die "could not open $certdata"; + +my $incert = 0; + +while ( ) +{ + if ( /^CKA_VALUE MULTILINE_OCTAL/ ) + { + $incert = 1; + open( OUT, "|openssl x509 -text -inform DER -fingerprint" ) + || die "could not pipe to openssl x509"; + } + + elsif ( /^END/ && $incert ) + { + close( OUT ); + $incert = 0; + print "\n\n"; + } + + elsif ($incert) + { + my @bs = split( /\\/ ); + foreach my $b (@bs) + { + chomp $b; + printf( OUT "%c", oct($b) ) unless $b eq ''; + } + } +}