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 hash method sha1 with resource **\n"; 25$r = openssl_x509_read($cert); 26var_dump(openssl_x509_fingerprint($r, 'sha1')); 27 28echo "** Testing bad certification **\n"; 29var_dump(openssl_x509_fingerprint('123')); 30echo "** Testing bad hash method **\n"; 31var_dump(openssl_x509_fingerprint($cert, 'xx45')); 32?> 33--EXPECTF-- 34** Testing with no parameters ** 35 36Warning: openssl_x509_fingerprint() expects at least 1 parameter, 0 given in %s on line %d 37NULL 38** Testing default functionality ** 39string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" 40** Testing hash method md5 ** 41string(32) "ac77008e172897e06c0b065294487a67" 42**Testing raw output md5 ** 43string(32) "ac77008e172897e06c0b065294487a67" 44** Testing hash method sha1 with resource ** 45string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" 46** Testing bad certification ** 47 48Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in %s on line %d 49bool(false) 50** Testing bad hash method ** 51 52Warning: openssl_x509_fingerprint(): Unknown signature algorithm in %s on line %d 53bool(false) 54 55