Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestSSLCA.pm view on Meta::CPAN
my @parts = (qw(C ST L O OU CN), $email_field);
@parts = reverse @parts if $rfc2253;
for my $k (@parts) {
next unless $dn->{$k};
if ($rfc2253) {
my $tmp = $dn->{$k};
$tmp =~ s{([,+"\\<>;])}{\\$1}g;
$tmp =~ s{^([ #])}{\\$1};
$tmp =~ s{ $}{\\ };
$string .= "," if $string;
$string .= "$k=$tmp";
}
else {
$string .= "/$k=$dn->{$k}";
}
}
$string;
}
sub openssl {
return $openssl unless @_;
my $cmd = "$openssl @_";
info $cmd;
unless (system($cmd) == 0) {
my $status = $? >> 8;
die "system @_ failed (exit status=$status)";
}
}
my @dirs = qw(keys newcerts certs crl export csr conf proxy);
sub init {
for my $dir (@dirs) {
gendir($dir);
}
}
sub config_file {
my $name = shift;
my $file = "conf/$name.cnf";
return $file if -e $file;
my $dn = dn($name);
my $db = SSLCA_DB;
writefile($db, '', 1) unless -e $db;
writefile($file, <<EOF);
mail = $dn->{$email_field}
CN = $dn->{CN}
[ req ]
distinguished_name = req_distinguished_name
attributes = req_attributes
prompt = no
default_bits = 2048
output_password = $pass
[ req_distinguished_name ]
C = $dn->{C}
ST = $dn->{ST}
L = $dn->{L}
O = $dn->{O}
OU = $dn->{OU}
CN = \$CN
$email_field = \$mail
[ req_attributes ]
challengePassword = $pass
[ ca ]
default_ca = CA_default
[ CA_default ]
certs = certs # Where the issued certs are kept
new_certs_dir = newcerts # default place for new certs.
crl_dir = crl # Where the issued crl are kept
database = $db # database index file.
serial = serial # The current serial number
certificate = $cacert # The CA certificate
crl = $cacrl # The current CRL
private_key = $cakey # The private key
default_days = 365 # how long to certify for
default_crl_days = 365 # how long before next CRL
default_md = $dgst # which md to use.
preserve = no # keep passed DN ordering
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
$email_field = optional
[ client_ok_ext ]
nsComment = This Is A Comment
1.3.6.1.4.1.18060.12.0 = DER:0c064c656d6f6e73
subjectAltName = email:\$mail$san_msupn
[ server_ext ]
subjectAltName = DNS:\$CN$san_dnssrv
EOF
return $file;
}
sub config {
my $name = shift;
my $file = config_file($name);
( run in 0.965 second using v1.01-cache-2.11-cpan-6aa56a78535 )