Advertisement
Guest User

Untitled

a guest
Jul 29th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  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
  16.  
  17. my $certdata = './tempfile.cer';
  18.  
  19. open( IN, "cat $certdata|" )
  20. || die "could not open $certdata";
  21.  
  22. my $incert = 0;
  23.  
  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. }
  32.  
  33. elsif ( /^END/ && $incert )
  34. {
  35. close( OUT );
  36. $incert = 0;
  37. print "\n\n";
  38. }
  39.  
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement