<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
#
# Used to generate PEM encoded files from Mozilla certdata.txt.
# Run as ./mkcrt.pl &gt; 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

my $certdata = './tempfile.cer';

open(IN, "cat $certdata|")
    || die "could not open $certdata";

my $incert = 0;

while (&lt;IN&gt;) {
    if (/^CKA_VALUE MULTILINE_OCTAL/) {
        $incert = 1;
        open(OUT, "|openssl x509 -text -inform DER -fingerprint")
            || die "could not pipe to openssl x509";
    } elsif (/^END/ &amp;&amp; $incert) {
        close(OUT);
        $incert = 0;
        print "\n\n";
    } elsif ($incert) {
        my @bs = split(/\\/);
        foreach my $b (@bs) {
            chomp $b;
            printf(OUT "%c", oct($b)) unless $b eq '';
        }
    } 
}
</pre></body></html>