5 kx #!/usr/bin/perl -w
5 kx
5 kx # Used to generate PEM encoded files from Mozilla certdata.txt.
5 kx # Run as ./make-cert.pl > certificate.crt
5 kx #
5 kx # Parts of this script courtesy of RedHat (mkcabundle.pl)
5 kx #
5 kx # This script modified for use with single file data (tempfile.cer) extracted
5 kx # from certdata.txt, taken from the latest version in the Mozilla NSS source.
5 kx # mozilla/security/nss/lib/ckfw/builtins/certdata.txt
5 kx #
5 kx # Authors: DJ Lucas
5 kx # Bruce Dubbs
5 kx #
5 kx # Version 20120211
5 kx
5 kx my $certdata = './tempfile.cer';
5 kx
5 kx open( IN, "cat $certdata|" )
5 kx || die "could not open $certdata";
5 kx
5 kx my $incert = 0;
5 kx
5 kx while ( <IN> )
5 kx {
5 kx if ( /^CKA_VALUE MULTILINE_OCTAL/ )
5 kx {
5 kx $incert = 1;
5 kx open( OUT, "|openssl x509 -text -inform DER -fingerprint" )
5 kx || die "could not pipe to openssl x509";
5 kx }
5 kx
5 kx elsif ( /^END/ && $incert )
5 kx {
5 kx close( OUT );
5 kx $incert = 0;
5 kx print "\n\n";
5 kx }
5 kx
5 kx elsif ($incert)
5 kx {
5 kx my @bs = split( /\\/ );
5 kx foreach my $b (@bs)
5 kx {
5 kx chomp $b;
5 kx printf( OUT "%c", oct($b) ) unless $b eq '';
5 kx }
5 kx }
5 kx }