Created
April 19, 2015 03:36
-
-
Save holly/2ab5b1763c5563debd5e to your computer and use it in GitHub Desktop.
Used to generate PEM encoded files from Mozilla certdata.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Used to generate PEM encoded files from Mozilla certdata.txt. | |
# Run as ./make-cert.pl > certificate.crt | |
# | |
# Parts of this script courtesy of RedHat (mkcabundle.pl) | |
# | |
# This script modified for use with single file data (tempfile.cer) extracted | |
# from certdata.txt, taken from the latest version in the Mozilla NSS source. | |
# mozilla/security/nss/lib/ckfw/builtins/certdata.txt | |
# | |
# Authors: DJ Lucas | |
# Bruce Dubbs | |
# | |
# Version 20120211 | |
use strict; | |
use warnings; | |
use feature qw(say); | |
use FindBin qw($Script $Bin); | |
use Pod::Usage; | |
our $VERSION = '1.0'; | |
our $AUTHOR = 'holly'; | |
our $CERTDATA_URL = 'http://anduin.linuxfromscratch.org/sources/other/certdata.txt'; | |
my ($read_pipe, $write_pipe); | |
my $incert = 0; | |
open $read_pipe, "-|" or exec "curl", "-sL", $CERTDATA_URL or die $!; | |
while ( my $line = <$read_pipe> ) { | |
if ( $line =~ /^CKA_VALUE MULTILINE_OCTAL/ ) { | |
$incert = 1; | |
open $write_pipe, "|-" or exec "openssl", "x509", "-text", "-inform", "DER", "-fingerprint" || die "could not pipe to openssl x509"; | |
} elsif ( $line =~ /^END/ && $incert ) { | |
close $write_pipe; | |
$incert = 0; | |
print "\n\n"; | |
} elsif ($incert) { | |
my @bs = split( /\\/, $line ); | |
foreach my $b (@bs) { | |
chomp $b; | |
printf( $write_pipe "%c", oct($b) ) if $b ne ''; | |
} | |
} | |
} | |
close $read_pipe; | |
exit; | |
__END__ | |
=pod | |
=head1 NAME | |
make-cert.pl - description | |
=head1 VERSION | |
1.0 | |
=head1 SYNOPSIS | |
./make-cert.pl | |
=head1 DESCRIPTION | |
make root certficates file from http://anduin.linuxfromscratch.org/sources/other/certdata.txt | |
http://www.linuxfromscratch.org/blfs/view/svn/postlfs/cacerts.html | |
=head1 LICENSE | |
This library is free software; you can redistribute it and/or modify | |
it under the same terms as Perl itself. | |
=cut | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment