wok-current view cacerts/stuff/make-cert.pl @ rev 17449
Up dropbear (2014.66)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 16 18:51:42 2014 +0100 (2014-12-16) |
parents | |
children | f29d4912ea56 |
line source
1 #!/usr/bin/perl -w
3 # Used to generate PEM encoded files from Mozilla certdata.txt.
4 # Run as ./mkcrt.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 }