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