Search code examples
phpssl-certificatemd5sha1fingerprint

PHP SSL Certificate Fingerprint


I need display in web page fingerprints of SSL Certificate. Is it possible in PHP? The function

openssl_x509_parse

doesn't return SHA1 and MD5 fingerprints. How resolve this problem? Thanks.


Solution

  • I'd guess the easiest way is going to be to call openssl through system

    $fingerprint = str_replace("SHA1 Fingerprint=", '', system('openssl x509 -noout -in /path/to/your/cert.pem -fingerprint'));
    

    And yes, I know, this is nothing like a clean way of doing this - however, it's the only one I can think of of the top of my head!!!