openssl_x509_fingerprint_basic.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. openssl_x509_fingerprint() tests
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("openssl")) die("skip");
  6. ?>
  7. --FILE--
  8. <?php
  9. $cert = "file://" . dirname(__FILE__) . "/cert.crt";
  10. echo "** Testing with no parameters **\n";
  11. var_dump(openssl_x509_fingerprint());
  12. echo "** Testing default functionality **\n";
  13. var_dump(openssl_x509_fingerprint($cert));
  14. echo "** Testing hash method md5 **\n";
  15. var_dump(openssl_x509_fingerprint($cert, 'md5'));
  16. echo "**Testing raw output md5 **\n";
  17. var_dump(bin2hex(openssl_x509_fingerprint($cert, 'md5', true)));
  18. echo "** Testing bad certification **\n";
  19. var_dump(openssl_x509_fingerprint('123'));
  20. echo "** Testing bad hash method **\n";
  21. var_dump(openssl_x509_fingerprint($cert, 'xx45'));
  22. --EXPECTF--
  23. ** Testing with no parameters **
  24. Warning: openssl_x509_fingerprint() expects at least 1 parameter, 0 given in %s on line %d
  25. NULL
  26. ** Testing default functionality **
  27. string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c"
  28. ** Testing hash method md5 **
  29. string(32) "ac77008e172897e06c0b065294487a67"
  30. **Testing raw output md5 **
  31. string(32) "ac77008e172897e06c0b065294487a67"
  32. ** Testing bad certification **
  33. Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in %s on line %d
  34. bool(false)
  35. ** Testing bad hash method **
  36. Warning: openssl_x509_fingerprint(): Unknown signature algorithm in %s on line %d
  37. bool(false)