| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||||||||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||||||||
| 3 | # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||||||||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||||||||||||||||||||
| 5 | # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||||||||
| 6 | # the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| 13 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| 14 | # limitations under the License. | ||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||
| 16 | package Apache::TestSSLCA; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Cwd (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use DirHandle (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use File::Path (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use File::Copy 'cp'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use File::Spec::Functions qw(devnull); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Apache::TestConfig (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use Apache::TestTrace; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use constant SSLCA_DB => 'index.txt'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | use vars qw(@EXPORT_OK &import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | use subs qw(symlink); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | @EXPORT_OK = qw(dn dn_vars dn_oneline); | |||||||||||||||||||||||||||
| 37 | 1 | *import = \&Exporter::import; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my $openssl = $ENV{APACHE_TEST_OPENSSL_CMD} || 'openssl'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'APACHE_TEST_OPENSSL_CMD'} || 'openssl'
MC/DC0%0/1
$ENV{'APACHE_TEST_OPENSSL_CMD'} || 'openssl'
$ENV{'APACHE_TEST_OPENSSL_CMD'}
Truth table50%1/2
A
A= $ENV{'APACHE_TEST_OPENSSL_CMD'}
| |||||||||||||||||||||||||||||
| 40 | 1 | my $version = version(); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | my $CA = 'asf'; | |||||||||||||||||||||||||||
| 43 | 1 | my $Config; #global Apache::TestConfig object | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | my $days = '-days 365'; | |||||||||||||||||||||||||||
| 46 | 1 | my $cakey = 'keys/ca.pem'; | |||||||||||||||||||||||||||
| 47 | 1 | my $cacert = 'certs/ca.crt'; | |||||||||||||||||||||||||||
| 48 | 1 | my $capolicy = '-policy policy_anything'; | |||||||||||||||||||||||||||
| 49 | 1 | my $cacrl = 'crl/ca-bundle.crl'; | |||||||||||||||||||||||||||
| 50 | 1 | my $dgst = 'sha256'; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | #we use the same password for everything | ||||||||||||||||||||||||||||
| 53 | 1 | my $pass = 'httpd'; | |||||||||||||||||||||||||||
| 54 | 1 | my $passin = "-passin pass:$pass"; | |||||||||||||||||||||||||||
| 55 | 1 | my $passout = "-passout pass:$pass"; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # (limited) subjectAltName otherName testing | ||||||||||||||||||||||||||||
| 58 | 1 | my $san_msupn = ', otherName:msUPN;UTF8:$mail'; | |||||||||||||||||||||||||||
| 59 | 1 | my $san_dnssrv = ', otherName:1.3.6.1.5.5.7.8.7;IA5:_https.$CN'; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | # in 0.9.7 s/Email/emailAddress/ in DN | ||||||||||||||||||||||||||||
| 62 | 1 | ▶ | my $email_field = Apache::Test::normalize_vstring($version) < | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | Apache::Test::normalize_vstring("0.9.7") ? | ||||||||||||||||||||||||||||
| 64 | "Email" : "emailAddress"; | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # downgrade to SHA-1 for OpenSSL before 0.9.8 | ||||||||||||||||||||||||||||
| 67 | 1 | ▶ | if (Apache::Test::normalize_vstring($version) < | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | Apache::Test::normalize_vstring("0.9.8")) { | ||||||||||||||||||||||||||||
| 69 | 0 | $dgst = 'sha1'; | |||||||||||||||||||||||||||
| 70 | # otherNames in x509v3_config are not supported either | ||||||||||||||||||||||||||||
| 71 | 0 | $san_msupn = $san_dnssrv = ""; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | my $sslproto = "all"; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | eval { require Net::SSLeay; }; | |||||||||||||||||||||||||||
| 77 | 1 | ▶ | if (Apache::Test::normalize_vstring($version) >= | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
Apache::Test::normalize_vstring($version) >= Apache::Test::normalize_vstring("1.1.1") and not defined &Net::SSLeay::CTX_set_post_handshake_auth
MC/DC0%0/2
Apache::Test::normalize_vstring($version) >= Apache::Test::normalize_vstring("1.1.1") and not defined &Net::SSLeay::CTX_set_post_handshake_auth
Apache::Test::normalize_vstring($version) >= Apache::Test::normalize_vstring("1.1.1")
not defined &Net::SSLeay::CTX_set_post_handshake_auth
Truth table33%1/3
A and not(B)
A= Apache::Test::normalize_vstring($version) >= Apache::Test::normalize_vstring("1.1.1")B= not defined &Net::SSLeay::CTX_set_post_handshake_auth
| |||||||||||||||||||||||||||||
| 78 | Apache::Test::normalize_vstring("1.1.1") | ||||||||||||||||||||||||||||
| 79 | && !defined(&Net::SSLeay::CTX_set_post_handshake_auth)) { | ||||||||||||||||||||||||||||
| 80 | # OpenSSL 1.1.1 disables PHA by default client-side in TLSv1.3 but | ||||||||||||||||||||||||||||
| 81 | # most clients are not updated to enable it (at time of writing). | ||||||||||||||||||||||||||||
| 82 | # Many mod_ssl tests require working PHA, so disable v1.3 unless | ||||||||||||||||||||||||||||
| 83 | # using an updated Net::SSLeay. This is strictly insufficient | ||||||||||||||||||||||||||||
| 84 | # since an updated IO::Socket::SSL is also needed; to be | ||||||||||||||||||||||||||||
| 85 | # continued. Ref: https://github.com/openssl/openssl/issues/6933 | ||||||||||||||||||||||||||||
| 86 | 0 | $sslproto = "all -TLSv1.3"; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | my $ca_dn = { | |||||||||||||||||||||||||||
| 90 | asf => { | ||||||||||||||||||||||||||||
| 91 | C => 'US', | ||||||||||||||||||||||||||||
| 92 | ST => 'California', | ||||||||||||||||||||||||||||
| 93 | L => 'San Francisco', | ||||||||||||||||||||||||||||
| 94 | O => 'ASF', | ||||||||||||||||||||||||||||
| 95 | OU => 'httpd-test', | ||||||||||||||||||||||||||||
| 96 | CN => '', | ||||||||||||||||||||||||||||
| 97 | $email_field => 'test-dev@httpd.apache.org', | ||||||||||||||||||||||||||||
| 98 | }, | ||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 1 | my $cert_dn = { | |||||||||||||||||||||||||||
| 102 | client_snakeoil => { | ||||||||||||||||||||||||||||
| 103 | C => 'AU', | ||||||||||||||||||||||||||||
| 104 | ST => 'Queensland', | ||||||||||||||||||||||||||||
| 105 | L => 'Mackay', | ||||||||||||||||||||||||||||
| 106 | O => 'Snake Oil, Ltd.', | ||||||||||||||||||||||||||||
| 107 | OU => 'Staff', | ||||||||||||||||||||||||||||
| 108 | }, | ||||||||||||||||||||||||||||
| 109 | client_ok => { | ||||||||||||||||||||||||||||
| 110 | }, | ||||||||||||||||||||||||||||
| 111 | client_colon => { | ||||||||||||||||||||||||||||
| 112 | CN => "user:colon", | ||||||||||||||||||||||||||||
| 113 | }, | ||||||||||||||||||||||||||||
| 114 | client_revoked => { | ||||||||||||||||||||||||||||
| 115 | }, | ||||||||||||||||||||||||||||
| 116 | server => { | ||||||||||||||||||||||||||||
| 117 | CN => 'localhost', | ||||||||||||||||||||||||||||
| 118 | OU => 'httpd-test/rsa-test', | ||||||||||||||||||||||||||||
| 119 | }, | ||||||||||||||||||||||||||||
| 120 | server2 => { | ||||||||||||||||||||||||||||
| 121 | CN => 'localhost', | ||||||||||||||||||||||||||||
| 122 | OU => 'httpd-test/rsa-test-2', | ||||||||||||||||||||||||||||
| 123 | }, | ||||||||||||||||||||||||||||
| 124 | server_des3 => { | ||||||||||||||||||||||||||||
| 125 | CN => 'localhost', | ||||||||||||||||||||||||||||
| 126 | OU => 'httpd-test/rsa-des3-test', | ||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||
| 128 | server2_des3 => { | ||||||||||||||||||||||||||||
| 129 | CN => 'localhost', | ||||||||||||||||||||||||||||
| 130 | OU => 'httpd-test/rsa-des3-test-2', | ||||||||||||||||||||||||||||
| 131 | }, | ||||||||||||||||||||||||||||
| 132 | }; | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | #generate DSA versions of the server certs/keys | ||||||||||||||||||||||||||||
| 135 | 1 | for my $key (keys %$cert_dn) { | |||||||||||||||||||||||||||
| 136 | 8 | ▶ | next unless $key =~ /^server/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 4 | my $val = $$cert_dn{$key}; | |||||||||||||||||||||||||||
| 138 | 4 | my $name = join '_', $key, 'dsa'; | |||||||||||||||||||||||||||
| 139 | 4 | $cert_dn->{$name} = { %$val }; #copy | |||||||||||||||||||||||||||
| 140 | 4 | $cert_dn->{$name}->{OU} =~ s/rsa/dsa/; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub ca_dn { | ||||||||||||||||||||||||||
|
Subroutine
ca_dn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | $ca_dn = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | $ca_dn; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub cert_dn { | ||||||||||||||||||||||||||
|
Subroutine
cert_dn: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $cert_dn = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | $cert_dn; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub dn { | ||||||||||||||||||||||||||
|
Subroutine
dn: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 154 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | my %dn = %{ $ca_dn->{$CA} }; #default values | |||||||||||||||||||||||||||
| 157 | 0 | ▶ | $dn{CN} ||= $name; #try make sure each Common Name is different | ||||||||||||||||||||||||||
|
Condition0%0/3
$dn{"CN"} ||= $name
MC/DC0%0/2
$dn{"CN"} ||= $name
$dn{"CN"}
$name
Truth table0%0/3
A ||= B
A= $dn{"CN"}B= $name
| |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | my $default_dn = $cert_dn->{$name}; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($default_dn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | while (my($key, $value) = each %$default_dn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | #override values | ||||||||||||||||||||||||||||
| 164 | 0 | $dn{$key} = $value; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return wantarray ? %dn : \%dn; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub dn_vars { | ||||||||||||||||||||||||||
|
Subroutine
dn_vars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 172 | 0 | my($name, $type) = @_; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | my $dn = dn($name); | |||||||||||||||||||||||||||
| 175 | 0 | my $prefix = join '_', 'SSL', $type, 'DN'; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 0 | return { map { $prefix ."_$_", $dn->{$_} } keys %$dn }; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub dn_oneline { | ||||||||||||||||||||||||||
|
Subroutine
dn_oneline: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 181 | 0 | my($dn, $rfc2253) = @_; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | unless (ref $dn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 0 | $dn = dn($dn); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my $string = ""; | |||||||||||||||||||||||||||
| 188 | 0 | my @parts = (qw(C ST L O OU CN), $email_field); | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | @parts = reverse @parts if $rfc2253; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | for my $k (@parts) { | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | next unless $dn->{$k}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($rfc2253) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 0 | my $tmp = $dn->{$k}; | |||||||||||||||||||||||||||
| 195 | 0 | $tmp =~ s{([,+"\\<>;])}{\\$1}g; | |||||||||||||||||||||||||||
| 196 | 0 | $tmp =~ s{^([ #])}{\\$1}; | |||||||||||||||||||||||||||
| 197 | 0 | $tmp =~ s{ $}{\\ }; | |||||||||||||||||||||||||||
| 198 | 0 | ▶ | $string .= "," if $string; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | $string .= "$k=$tmp"; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||
| 202 | 0 | $string .= "/$k=$dn->{$k}"; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | $string; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub openssl { | ||||||||||||||||||||||||||
|
Subroutine
openssl: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 210 | 0 | ▶ | return $openssl unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | my $cmd = "$openssl @_"; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | info $cmd; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | unless (system($cmd) == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 0 | my $status = $? >> 8; | |||||||||||||||||||||||||||
| 218 | 0 | die "system @_ failed (exit status=$status)"; | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 1 | my @dirs = qw(keys newcerts certs crl export csr conf proxy); | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 225 | 0 | for my $dir (@dirs) { | |||||||||||||||||||||||||||
| 226 | 0 | gendir($dir); | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub config_file { | ||||||||||||||||||||||||||
|
Subroutine
config_file: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 231 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | my $file = "conf/$name.cnf"; | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | return $file if -e $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | my $dn = dn($name); | |||||||||||||||||||||||||||
| 237 | 0 | my $db = SSLCA_DB; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | writefile($db, '', 1) unless -e $db; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | writefile($file, <<EOF); | |||||||||||||||||||||||||||
| 242 | mail = $dn->{$email_field} | ||||||||||||||||||||||||||||
| 243 | CN = $dn->{CN} | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | [ req ] | ||||||||||||||||||||||||||||
| 246 | distinguished_name = req_distinguished_name | ||||||||||||||||||||||||||||
| 247 | attributes = req_attributes | ||||||||||||||||||||||||||||
| 248 | prompt = no | ||||||||||||||||||||||||||||
| 249 | default_bits = 2048 | ||||||||||||||||||||||||||||
| 250 | output_password = $pass | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | [ req_distinguished_name ] | ||||||||||||||||||||||||||||
| 253 | C = $dn->{C} | ||||||||||||||||||||||||||||
| 254 | ST = $dn->{ST} | ||||||||||||||||||||||||||||
| 255 | L = $dn->{L} | ||||||||||||||||||||||||||||
| 256 | O = $dn->{O} | ||||||||||||||||||||||||||||
| 257 | OU = $dn->{OU} | ||||||||||||||||||||||||||||
| 258 | CN = \$CN | ||||||||||||||||||||||||||||
| 259 | $email_field = \$mail | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | [ req_attributes ] | ||||||||||||||||||||||||||||
| 262 | challengePassword = $pass | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | [ ca ] | ||||||||||||||||||||||||||||
| 265 | default_ca = CA_default | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | [ CA_default ] | ||||||||||||||||||||||||||||
| 268 | certs = certs # Where the issued certs are kept | ||||||||||||||||||||||||||||
| 269 | new_certs_dir = newcerts # default place for new certs. | ||||||||||||||||||||||||||||
| 270 | crl_dir = crl # Where the issued crl are kept | ||||||||||||||||||||||||||||
| 271 | database = $db # database index file. | ||||||||||||||||||||||||||||
| 272 | serial = serial # The current serial number | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | certificate = $cacert # The CA certificate | ||||||||||||||||||||||||||||
| 275 | crl = $cacrl # The current CRL | ||||||||||||||||||||||||||||
| 276 | private_key = $cakey # The private key | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | default_days = 365 # how long to certify for | ||||||||||||||||||||||||||||
| 279 | default_crl_days = 365 # how long before next CRL | ||||||||||||||||||||||||||||
| 280 | default_md = $dgst # which md to use. | ||||||||||||||||||||||||||||
| 281 | preserve = no # keep passed DN ordering | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | [ policy_anything ] | ||||||||||||||||||||||||||||
| 284 | countryName = optional | ||||||||||||||||||||||||||||
| 285 | stateOrProvinceName = optional | ||||||||||||||||||||||||||||
| 286 | localityName = optional | ||||||||||||||||||||||||||||
| 287 | organizationName = optional | ||||||||||||||||||||||||||||
| 288 | organizationalUnitName = optional | ||||||||||||||||||||||||||||
| 289 | commonName = supplied | ||||||||||||||||||||||||||||
| 290 | $email_field = optional | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | [ client_ok_ext ] | ||||||||||||||||||||||||||||
| 293 | nsComment = This Is A Comment | ||||||||||||||||||||||||||||
| 294 | 1.3.6.1.4.1.18060.12.0 = DER:0c064c656d6f6e73 | ||||||||||||||||||||||||||||
| 295 | subjectAltName = email:\$mail$san_msupn | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | [ server_ext ] | ||||||||||||||||||||||||||||
| 298 | subjectAltName = DNS:\$CN$san_dnssrv | ||||||||||||||||||||||||||||
| 299 | EOF | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | return $file; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 305 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | my $file = config_file($name); | |||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | my $config = "-config $file"; | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | $config; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 1 | ▶ | use constant PASSWORD_CLEARTEXT => | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 315 | 1 | Apache::TestConfig::WIN32 || Apache::TestConfig::NETWARE; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | #http://www.modssl.org/docs/2.8/ssl_reference.html#ToC21 | ||||||||||||||||||||||||||||
| 318 | 1 | my $basic_auth_password = | |||||||||||||||||||||||||||
| 319 | PASSWORD_CLEARTEXT ? 'password': 'xxj31ZMTZzkVA'; | ||||||||||||||||||||||||||||
| 320 | 1 | my $digest_auth_hash = '$1$OXLyS...$Owx8s2/m9/gfkcRVXzgoE/'; | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub new_ca { | ||||||||||||||||||||||||||
|
Subroutine
new_ca: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 323 | 0 | writefile('serial', "01\n", 1); | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 0 | writefile('ssl.htpasswd', | |||||||||||||||||||||||||||
| 326 | join ':', dn_oneline('client_snakeoil'), | ||||||||||||||||||||||||||||
| 327 | $basic_auth_password); | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | openssl req => "-new -x509 -keyout $cakey -out $cacert $days", | |||||||||||||||||||||||||||
| 330 | config('ca'); | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | export_cert('ca'); #useful for importing into IE | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | ▶ | sub new_key { | ||||||||||||||||||||||||||
|
Subroutine
new_key: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 336 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $encrypt = @_ ? "@_ $passout" : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 0 | my $out = "-out keys/$name.pem $encrypt"; | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($name =~ /dsa/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | #this takes a long time so just do it once | ||||||||||||||||||||||||||||
| 344 | #don't do this in real life | ||||||||||||||||||||||||||||
| 345 | 0 | ▶ | unless (-e 'dsa-param') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | 0 | openssl dsaparam => '-inform PEM -out dsa-param 2048'; | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | 0 | openssl gendsa => "$out dsa-param"; | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | else { | ||||||||||||||||||||||||||||
| 351 | 0 | openssl genrsa => "$out 2048"; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub new_cert { | ||||||||||||||||||||||||||
|
Subroutine
new_cert: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 356 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 0 | openssl req => "-new -key keys/$name.pem -out csr/$name.csr", | |||||||||||||||||||||||||||
| 359 | $passin, $passout, config($name); | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | sign_cert($name); | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | export_cert($name); | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub sign_cert { | ||||||||||||||||||||||||||
|
Subroutine
sign_cert: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 367 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 368 | 0 | my $exts = ''; | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $exts = ' -extensions client_ok_ext' if $name =~ /client_ok/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | ▶ | $exts = ' -extensions server_ext' if $name =~ /server/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 0 | openssl ca => "$capolicy -in csr/$name.csr -out certs/$name.crt", | |||||||||||||||||||||||||||
| 375 | $passin, config($name), '-batch', $exts; | ||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | #handy for importing into a browser such as netscape | ||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub export_cert { | ||||||||||||||||||||||||||
|
Subroutine
export_cert: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 380 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | ▶ | return if $name =~ /^server/; #no point in exporting server certs | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 0 | openssl pkcs12 => "-export -in certs/$name.crt -inkey keys/$name.pem", | |||||||||||||||||||||||||||
| 385 | "-out export/$name.p12", $passin, $passout; | ||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub revoke_cert { | ||||||||||||||||||||||||||
|
Subroutine
revoke_cert: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 389 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 0 | my @args = (config('cacrl'), $passin); | |||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | #revokes in the SSLCA_DB database | ||||||||||||||||||||||||||||
| 394 | 0 | openssl ca => "-revoke certs/$name.crt", @args; | |||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | #generates crl from the index.txt database | ||||||||||||||||||||||||||||
| 397 | 0 | openssl ca => "-gencrl -out $cacrl", @args; | |||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub symlink { | ||||||||||||||||||||||||||
|
Subroutine
symlink: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 401 | 0 | my($file, $symlink) = @_; | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | my $what = 'linked'; | |||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | if (Apache::TestConfig::WINFU) { | |||||||||||||||||||||||||||
| 406 | cp $file, $symlink; | ||||||||||||||||||||||||||||
| 407 | $what = 'copied'; | ||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | else { | ||||||||||||||||||||||||||||
| 410 | 0 | CORE::symlink($file, $symlink); | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | info "$what $file to $symlink"; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub hash_certs { | ||||||||||||||||||||||||||
|
Subroutine
hash_certs: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 417 | 0 | my($type, $dir) = @_; | |||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | chdir $dir; | |||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | my $dh = DirHandle->new('.') or die "opendir $dir: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 0 | my $n = 0; | |||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | for my $file ($dh->read) { | |||||||||||||||||||||||||||
| 425 | 0 | ▶ | next unless $file =~ /\.cr[tl]$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | 0 | chomp(my $hash = `$openssl $type -noout -hash < $file`); | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | next unless $hash; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | my $symlink = "$hash.r$n"; | |||||||||||||||||||||||||||
| 429 | 0 | $n++; | |||||||||||||||||||||||||||
| 430 | 0 | symlink $file, $symlink; | |||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | 0 | close $dh; | |||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 0 | chdir $CA; | |||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 0 | ▶ | sub make_proxy_cert { | ||||||||||||||||||||||||||
|
Subroutine
make_proxy_cert: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 439 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | my $from = "certs/$name.crt"; | |||||||||||||||||||||||||||
| 442 | 0 | my $to = "proxy/$name.pem"; | |||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 0 | info "generating proxy cert: $to"; | |||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 0 | my $fh_to = Symbol::gensym(); | |||||||||||||||||||||||||||
| 447 | 0 | my $fh_from = Symbol::gensym(); | |||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | 0 | ▶ | open $fh_to, ">$to" or die "open $to: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 450 | 0 | ▶ | open $fh_from, $from or die "open $from: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | cp $fh_from, $fh_to; | |||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | 0 | $from = "keys/$name.pem"; | |||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 0 | ▶ | open $fh_from, $from or die "open $from: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 0 | cp $fh_from, $fh_to; | |||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | 0 | close $fh_from; | |||||||||||||||||||||||||||
| 461 | 0 | close $fh_to; | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | ▶ | sub setup { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 465 | 0 | $CA = shift; | |||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless ($ca_dn->{$CA}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | die "unknown CA $CA"; | |||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 0 | gendir($CA); | |||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | chdir $CA; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | init(); | |||||||||||||||||||||||||||
| 476 | 0 | new_ca(); | |||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 0 | my @names = keys %$cert_dn; | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | for my $name (@names) { | |||||||||||||||||||||||||||
| 481 | 0 | my @key_args = (); | |||||||||||||||||||||||||||
| 482 | 0 | ▶ | if ($name =~ /_des3/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 0 | push @key_args, '-des3'; | |||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | 0 | new_key($name, @key_args); | |||||||||||||||||||||||||||
| 487 | 0 | new_cert($name); | |||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if ($name =~ /_revoked$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 490 | 0 | revoke_cert($name); | |||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if ($name =~ /^client_/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 494 | 0 | make_proxy_cert($name); | |||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 0 | hash_certs(crl => 'crl'); | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub generate { | ||||||||||||||||||||||||||
|
Subroutine
generate: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 502 | 0 | $Config = shift; | |||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $CA = shift || $Config->{vars}->{sslcaorg}; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $Config->{'vars'}{'sslcaorg'}
MC/DC0%0/2
shift() || $Config->{'vars'}{'sslcaorg'}
shift()
$Config->{'vars'}{'sslcaorg'}
Truth table0%0/3
A || B
A= shift()B= $Config->{'vars'}{'sslcaorg'}
| |||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 0 | my $root = $Config->{vars}->{sslca}; | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return if -d $root; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 0 | my $pwd = Cwd::cwd(); | |||||||||||||||||||||||||||
| 511 | 0 | my $base = dirname $root; | |||||||||||||||||||||||||||
| 512 | 0 | my $dir = basename $root; | |||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 0 | chdir $base; | |||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | # Ensure the CNs used in the server certs match up with the | ||||||||||||||||||||||||||||
| 517 | # hostname being used for testing. | ||||||||||||||||||||||||||||
| 518 | 0 | ▶ | while (my($key, $val) = each %$cert_dn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | ▶ | next unless $key =~ /^server/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 520 | 0 | $val->{CN} = $Config->{vars}->{servername}; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | #make a note that we created the tree | ||||||||||||||||||||||||||||
| 524 | 0 | $Config->clean_add_path($root); | |||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 0 | gendir($dir); | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 0 | chdir $dir; | |||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 0 | warning "generating SSL CA for $CA"; | |||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 0 | setup($CA); | |||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | 0 | chdir $pwd; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 0 | ▶ | sub clean { | ||||||||||||||||||||||||||
|
Subroutine
clean: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 538 | 0 | my $config = shift; | |||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | #rel2abs adds same drive letter for win32 that clean_add_path added | ||||||||||||||||||||||||||||
| 541 | 0 | my $dir = File::Spec->rel2abs($config->{vars}->{sslca}); | |||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | 0 | ▶ | unless ($config->{clean}->{dirs}->{$dir}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 544 | 0 | return; #we did not generate this ca | |||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | 0 | ▶ | unless ($config->{clean_level} > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 548 | #skip t/TEST -conf | ||||||||||||||||||||||||||||
| 549 | 0 | warning "skipping regeneration of SSL CA; run t/TEST -clean to force"; | |||||||||||||||||||||||||||
| 550 | 0 | return; | |||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 0 | File::Path::rmtree([$dir], 1, 1); | |||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | #not using Apache::TestConfig methods because the openssl commands | ||||||||||||||||||||||||||||
| 557 | #will generate heaps of files we cannot keep track of | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 0 | ▶ | sub writefile { | ||||||||||||||||||||||||||
|
Subroutine
writefile: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 560 | 0 | my($file, $content) = @_; | |||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||
| 563 | 0 | ▶ | open $fh, ">$file" or die "open $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 564 | 0 | print $fh $content; | |||||||||||||||||||||||||||
| 565 | 0 | close $fh; | |||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | 0 | ▶ | sub gendir { | ||||||||||||||||||||||||||
|
Subroutine
gendir: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 569 | 0 | my($dir) = @_; | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 0 | ▶ | return if -d $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | 0 | mkdir $dir, 0755; | |||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 1 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 576 | 1 | my $devnull = devnull(); | |||||||||||||||||||||||||||
| 577 | 1 | my $version = qx($openssl version 2>$devnull); | |||||||||||||||||||||||||||
| 578 | 1 | ▶ | return $1 if $version =~ /^\S+SSL (\S+)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 579 | 0 | die "FATAL: unable to determine openssl version via `$openssl version` from: $version"; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | 0 | ▶ | sub dgst { | ||||||||||||||||||||||||||
|
Subroutine
dgst: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 583 | 0 | return $dgst; | |||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | 0 | ▶ | sub email_field { | ||||||||||||||||||||||||||
|
Subroutine
email_field: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 587 | 0 | return $email_field; | |||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | 2 | ▶ | sub sslproto { | ||||||||||||||||||||||||||
|
Subroutine
sslproto: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 591 | 2 | return $sslproto; | |||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 1 | 1; | |||||||||||||||||||||||||||
| 595 | __END__ | ||||||||||||||||||||||||||||