wok-6.x annotate cacerts/stuff/make-cert.pl @ rev 17865

Up: cacerts (20150325)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Mar 25 17:21:43 2015 +0200 (2015-03-25)
parents d805d3de4546
children
rev   line source
al@14468 1 #!/usr/bin/perl -w
al@14468 2
al@14468 3 # Used to generate PEM encoded files from Mozilla certdata.txt.
al@17865 4 # Run as ./make-cert.pl > certificate.crt
al@14468 5 #
al@14468 6 # Parts of this script courtesy of RedHat (mkcabundle.pl)
al@14468 7 #
al@14468 8 # This script modified for use with single file data (tempfile.cer) extracted
al@14468 9 # from certdata.txt, taken from the latest version in the Mozilla NSS source.
al@14468 10 # mozilla/security/nss/lib/ckfw/builtins/certdata.txt
al@14468 11 #
al@14468 12 # Authors: DJ Lucas
al@14468 13 # Bruce Dubbs
al@14468 14 #
al@14468 15 # Version 20120211
al@14468 16
al@14468 17 my $certdata = './tempfile.cer';
al@14468 18
al@14468 19 open( IN, "cat $certdata|" )
al@14468 20 || die "could not open $certdata";
al@14468 21
al@14468 22 my $incert = 0;
al@14468 23
al@14468 24 while ( <IN> )
al@14468 25 {
al@14468 26 if ( /^CKA_VALUE MULTILINE_OCTAL/ )
al@14468 27 {
al@14468 28 $incert = 1;
al@14468 29 open( OUT, "|openssl x509 -text -inform DER -fingerprint" )
al@14468 30 || die "could not pipe to openssl x509";
al@14468 31 }
al@14468 32
al@14468 33 elsif ( /^END/ && $incert )
al@14468 34 {
al@14468 35 close( OUT );
al@14468 36 $incert = 0;
al@14468 37 print "\n\n";
al@14468 38 }
al@14468 39
al@14468 40 elsif ($incert)
al@14468 41 {
al@14468 42 my @bs = split( /\\/ );
al@14468 43 foreach my $b (@bs)
al@14468 44 {
al@14468 45 chomp $b;
al@14468 46 printf( OUT "%c", oct($b) ) unless $b eq '';
al@14468 47 }
al@14468 48 }
al@14468 49 }