Apache-Test
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Apache/TestSSLCA.pm view on Meta::CPAN
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);
my $config = "-config $file";
$config;
}
use constant PASSWORD_CLEARTEXT =>
Apache::TestConfig::WIN32 || Apache::TestConfig::NETWARE;
#http://www.modssl.org/docs/2.8/ssl_reference.html#ToC21
my $basic_auth_password =
PASSWORD_CLEARTEXT ? 'password': 'xxj31ZMTZzkVA';
my $digest_auth_hash = '$1$OXLyS...$Owx8s2/m9/gfkcRVXzgoE/';
sub new_ca {
writefile('serial', "01\n", 1);
writefile('ssl.htpasswd',
join ':', dn_oneline('client_snakeoil'),
$basic_auth_password);
openssl req => "-new -x509 -keyout $cakey -out $cacert $days",
config('ca');
export_cert('ca'); #useful for importing into IE
}
sub new_key {
my $name = shift;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.428 second using v1.00-cache-2.02-grep-82fe00e-cpan-dad7e4baca0 )