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