1--TEST-- 2openssl_x509_fingerprint() tests 3--EXTENSIONS-- 4openssl 5--FILE-- 6<?php 7 8$cert = "file://" . __DIR__ . "/cert.crt"; 9 10echo "** Testing default functionality **\n"; 11var_dump(openssl_x509_fingerprint($cert)); 12 13echo "** Testing hash method md5 **\n"; 14var_dump(openssl_x509_fingerprint($cert, 'md5')); 15 16echo "**Testing raw output md5 **\n"; 17var_dump(bin2hex(openssl_x509_fingerprint($cert, 'md5', true))); 18 19echo "** Testing hash method sha1 with resource **\n"; 20$r = openssl_x509_read($cert); 21var_dump(openssl_x509_fingerprint($r, 'sha1')); 22 23echo "** Testing bad certification **\n"; 24var_dump(openssl_x509_fingerprint('123')); 25echo "** Testing bad hash method **\n"; 26var_dump(openssl_x509_fingerprint($cert, 'xx45')); 27?> 28--EXPECTF-- 29** Testing default functionality ** 30string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" 31** Testing hash method md5 ** 32string(32) "ac77008e172897e06c0b065294487a67" 33**Testing raw output md5 ** 34string(32) "ac77008e172897e06c0b065294487a67" 35** Testing hash method sha1 with resource ** 36string(40) "6e6fd1ea10a5a23071d61c728ee9b40df6dbc33c" 37** Testing bad certification ** 38 39Warning: openssl_x509_fingerprint(): X.509 Certificate cannot be retrieved in %s on line %d 40bool(false) 41** Testing bad hash method ** 42 43Warning: openssl_x509_fingerprint(): Unknown digest algorithm in %s on line %d 44bool(false) 45