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