php/php-src — pull request #464 by datibbaw (2013-09-20 09:15:32+00:00)
Title: openssl: certificate fingerprinting support

Adds the function `openssl_x509_digest()` to determine the fingerprint or hash of a certificate.

bool openssl_x509_digest(
mixed $x509,
string &$output
[, string $method = "sha1"
[, bool $raw_output = false
] ] )

Example:

$context = stream_context_create(['ssl' => ['capture_peer_cert' => true]]);
$f = fopen($url, 'rt', false, $context);
$options = stream_context_get_options($context);

openssl_x509_digest($options['ssl']['peer_certificate'], $result, 'sha256');
echo $result, "\n";

Any hash functions that `openssl_digest()` supports can be used.