bug50293.phpt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Bug #50293 (Several openssl functions ignore the VCWD)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("openssl")) die("skip openssl not loaded");
  6. ?>
  7. --FILE--
  8. <?php
  9. $cert = "file://" . __DIR__ . "/cert.crt";
  10. $priv = "file://" . __DIR__ . "/private_rsa_1024.key";
  11. $config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf';
  12. $dn = [
  13. "countryName" => "GB",
  14. "stateOrProvinceName" => "Berkshire",
  15. "localityName" => "Newbury",
  16. "organizationName" => "My Company Ltd",
  17. "commonName" => "Demo Cert",
  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. mkdir(__DIR__ . "/bug50293");
  27. chdir(__DIR__ . "/bug50293");
  28. $privkey = openssl_pkey_get_private('file://' . __DIR__ . '/private_ec.key');
  29. $csr = openssl_csr_new($dn, $privkey, $args);
  30. $sscert = openssl_csr_sign($csr, null, $privkey, 365, $args);
  31. openssl_csr_export($csr, $csrout);;
  32. openssl_x509_export($sscert, $certout);
  33. openssl_x509_export_to_file($sscert , "bug50293.crt", false);
  34. openssl_pkey_export_to_file($privkey, "bug50293.pem", null, $args);
  35. var_dump(
  36. file_exists("bug50293.crt"),
  37. file_exists("bug50293.pem")
  38. );
  39. ?>
  40. --CLEAN--
  41. <?php
  42. @unlink(__DIR__ . "/bug50293/bug50293.crt");
  43. @unlink(__DIR__ . "/bug50293/bug50293.pem");
  44. @rmdir(__DIR__ . "/bug50293");
  45. ?>
  46. --EXPECT--
  47. bool(true)
  48. bool(true)