Listing 2: Perl program to install CA ROOT certificate
#!/usr/local/bin/perl
$CAROOT="demoCA";
$cert = "$CAROOT/cacert.pem";
open CERT, "<$cert" or die "certificate: $!\n";
@full = <CERT>;
close CERT;
$size = 0;
shift @full until( $full[0] =~ /-----BEGIN CERTIFICATE-----/ );
shift @full;
push @cert, shift @full until( ($size += (length( $cert[$#cert]) )) \ && $full[0] =~ /-----END
CERTIFICATE-----/ );
$size += length( "-----BEGIN CERTIFICATE-----\n" );
$size += length( "-----END CERTIFICATE-----\n" );
print "HTTP/1.0 200 \n";
print "Content-Type: application/x-x509-ca-cert\n";
print "Content-Encoding: base64\n";
print "Content-Length: " . $size . "\n\n";
print "-----BEGIN CERTIFICATE-----\n";
foreach (@cert) { chomp; print"$_\n"; }
print "-----END CERTIFICATE-----\n";
# End of File
|