openssl_x509_read_basic.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. openssl_x509_read() tests
  3. --SKIPIF--
  4. <?php if (!extension_loaded("openssl")) print "skip"; ?>
  5. --FILE--
  6. <?php
  7. $fp = fopen(dirname(__FILE__) . "/cert.crt","r");
  8. $a = fread($fp,8192);
  9. fclose($fp);
  10. $b = "file://" . dirname(__FILE__) . "/cert.crt";
  11. $c = "invalid cert";
  12. $d = openssl_x509_read($a);
  13. $e = array();
  14. $f = array($b);
  15. var_dump(openssl_x509_read($a)); // read cert as a string
  16. var_dump(openssl_x509_read($b)); // read cert as a filename string
  17. var_dump(openssl_x509_read($c)); // read an invalid cert, fails
  18. var_dump(openssl_x509_read($d)); // read cert from a resource
  19. var_dump(openssl_x509_read($e)); // read an array
  20. var_dump(openssl_x509_read($f)); // read an array with the filename
  21. ?>
  22. --EXPECTF--
  23. resource(%d) of type (OpenSSL X.509)
  24. resource(%d) of type (OpenSSL X.509)
  25. Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
  26. bool(false)
  27. resource(%d) of type (OpenSSL X.509)
  28. Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
  29. bool(false)
  30. Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d
  31. bool(false)