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