Skip to content

Commit 2f78c1f

Browse files
committed
Fix and improve OpenSSL VCWD path checking test for bug #50293
1 parent cb9a48a commit 2f78c1f

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

ext/openssl/tests/bug50293.phpt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,36 @@ if (!extension_loaded("openssl")) die("skip openssl not loaded");
66
?>
77
--FILE--
88
<?php
9-
$ssl_configargs = [
10-
"digest_alg" => "sha1",
11-
"encrypt_key" => false,
12-
"basicConstraints" => "CA:true",
13-
"keyUsage" => "cRLSign, keyCertSign",
14-
"nsCertType" => "sslCA, emailCA",
15-
"config" => __DIR__ . "/openssl.cnf",
16-
];
9+
$cert = "file://" . __DIR__ . "/cert.crt";
10+
$priv = "file://" . __DIR__ . "/private_rsa_1024.key";
11+
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
12+
1713
$dn = [
1814
"countryName" => "GB",
1915
"stateOrProvinceName" => "Berkshire",
2016
"localityName" => "Newbury",
2117
"organizationName" => "My Company Ltd",
2218
"commonName" => "Demo Cert",
2319
];
24-
$numberofdays = '365';
20+
21+
$args = array(
22+
"digest_alg" => "sha256",
23+
"private_key_bits" => 2048,
24+
"private_key_type" => OPENSSL_KEYTYPE_RSA,
25+
"encrypt_key" => true,
26+
"config" => $config
27+
);
2528

2629
mkdir(__DIR__ . "/bug50293");
2730
chdir(__DIR__ . "/bug50293");
2831

29-
$privkey = openssl_pkey_new($ssl_configargs);
30-
$csr = openssl_csr_new($dn, $privkey, $ssl_configargs);
31-
$sscert = openssl_csr_sign($csr, null, $privkey, $numberofdays);
32-
openssl_csr_export($csr, $csrout);
32+
$privkey = openssl_pkey_get_private('file://' . __DIR__ . '/private_ec.key');
33+
$csr = openssl_csr_new($dn, $privkey, $args);
34+
$sscert = openssl_csr_sign($csr, null, $privkey, 365, $args);
35+
openssl_csr_export($csr, $csrout);;
3336
openssl_x509_export($sscert, $certout);
3437
openssl_x509_export_to_file($sscert , "bug50293.crt", false);
35-
openssl_pkey_export($privkey, $pkeyout);
36-
openssl_pkey_export_to_file($privkey, "bug50293.pem");
38+
openssl_pkey_export_to_file($privkey, "bug50293.pem", null, $args);
3739

3840
var_dump(
3941
file_exists("bug50293.crt"),

0 commit comments

Comments
 (0)