forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbug50293.phpt
51 lines (46 loc) · 1.3 KB
/
bug50293.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--TEST--
Bug #50293 (Several openssl functions ignore the VCWD)
--EXTENSIONS--
openssl
--FILE--
<?php
$cert = "file://" . __DIR__ . "/cert.crt";
$priv = "file://" . __DIR__ . "/private_rsa_1024.key";
$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
$dn = [
"countryName" => "GB",
"stateOrProvinceName" => "Berkshire",
"localityName" => "Newbury",
"organizationName" => "My Company Ltd",
"commonName" => "Demo Cert",
];
$args = array(
"digest_alg" => "sha256",
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
"encrypt_key" => true,
"config" => $config
);
mkdir(__DIR__ . "/bug50293");
chdir(__DIR__ . "/bug50293");
$privkey = openssl_pkey_get_private('file://' . __DIR__ . '/private_ec.key');
$csr = openssl_csr_new($dn, $privkey, $args);
$sscert = openssl_csr_sign($csr, null, $privkey, 365, $args);
openssl_csr_export($csr, $csrout);;
openssl_x509_export($sscert, $certout);
openssl_x509_export_to_file($sscert , "bug50293.crt", false);
openssl_pkey_export_to_file($privkey, "bug50293.pem", null, $args);
var_dump(
file_exists("bug50293.crt"),
file_exists("bug50293.pem")
);
?>
--CLEAN--
<?php
@unlink(__DIR__ . "/bug50293/bug50293.crt");
@unlink(__DIR__ . "/bug50293/bug50293.pem");
@rmdir(__DIR__ . "/bug50293");
?>
--EXPECT--
bool(true)
bool(true)