openssl_x509_verify.phpt 709 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. openssl_x509_verify() tests
  3. --EXTENSIONS--
  4. openssl
  5. --FILE--
  6. <?php
  7. $fp = fopen(__DIR__ . "/cert.crt","r");
  8. $a = fread($fp, 8192);
  9. fclose($fp);
  10. $fp = fopen(__DIR__ . "/public.key","r");
  11. $b = fread($fp, 8192);
  12. fclose($fp);
  13. $cert = "file://" . __DIR__ . "/cert.crt";
  14. $key = "file://" . __DIR__ . "/public.key";
  15. $wrongKey = "file://" . __DIR__ . "/public_rsa_2048.key";
  16. var_dump(openssl_x509_verify($cert, $key));
  17. var_dump(openssl_x509_verify("", $key));
  18. var_dump(openssl_x509_verify($cert, ""));
  19. var_dump(openssl_x509_verify("", ""));
  20. var_dump(openssl_x509_verify(openssl_x509_read($a), $b));
  21. var_dump(openssl_x509_verify($cert, $wrongKey));
  22. ?>
  23. --EXPECT--
  24. int(1)
  25. int(-1)
  26. int(-1)
  27. int(-1)
  28. int(1)
  29. int(0)