openssl_csr_new_basic.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. openssl_csr_new() tests
  3. --SKIPIF--
  4. <?php if (!extension_loaded("openssl")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. $a = 1;
  8. var_dump(openssl_csr_new(1,$a));
  9. var_dump(openssl_csr_new(1,$a,1,1));
  10. $a = array();
  11. $conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf');
  12. var_dump(openssl_csr_new(array(), $a, $conf, array()));
  13. // this leaks
  14. $a = array(1,2);
  15. $b = array(1,2);
  16. var_dump(openssl_csr_new($a, $b, $conf));
  17. // options type check
  18. $x = openssl_pkey_new($conf);
  19. var_dump(openssl_csr_new(["countryName" => "DE"], $x, $conf + ["x509_extensions" => 0xDEADBEEF]));
  20. echo "Done\n";
  21. ?>
  22. --EXPECTF--
  23. Warning: openssl_csr_new() expects parameter 1 to be array, int given in %s on line %d
  24. NULL
  25. Warning: openssl_csr_new() expects parameter 1 to be array, int given in %s on line %d
  26. NULL
  27. Warning: openssl_csr_new(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d
  28. Warning: openssl_csr_new(): add1_attr_by_txt challengePassword_min -> 4 (failed; check error queue and value of string_mask OpenSSL option if illegal characters are reported) in %s on line %d
  29. bool(false)
  30. resource(%d) of type (OpenSSL X.509 CSR)
  31. resource(%d) of type (OpenSSL X.509 CSR)
  32. Done