php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53785 Way to query a X.509 certificate fingerprint
Submitted: 2011-01-19 06:38 UTC Modified: 2013-10-08 14:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: BenBE at geshi dot org Assigned: mike (profile)
Status: Closed Package: OpenSSL related
PHP Version: 5.3.5 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: BenBE at geshi dot org
New email:
PHP Version: OS:

 

 [2011-01-19 06:38 UTC] BenBE at geshi dot org
Description:
------------
When reading a X.509 certificate file (or fetching the certificate from an SSL connection) there is no straight forward way to query the certificate's fingerprint as shown by browsers when viewing the site's certificate.

The output of openssl_x509_parse doesn't contain the fingerprint while openssl_x509_export might contain it in a hard to parse string representation.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-27 09:29 UTC] msn at searchy dot nl
The fingerprint is nothing more than the md5 or sha1 sum of the certificate. When you take ther certificate, strip it of the begin and end tag, base64 decode the content and md5 that, you'll get the fingerprint. 

Sample code: 

$newcert = preg_replace("/-----BEGIN CERTIFICATE-----|-----END CERTIFICATE-----/","",$cert); 

$b64 = base64_decode($newcert);
echo "MD5 fingerprint: " . md5($b64) . "\n";
 [2013-10-08 14:21 UTC] mike@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 [2013-10-08 14:21 UTC] mike@php.net
Feature by Tjerk Meesters in master.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC