PHP

cert_pin.php


<?php
$domain = "urip.io";
$json_url = "https://api.cert.ist/$domain";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
$hash = $data["openssl"]["pubkey"]['der_sha256'];

$ch = curl_init("https://$domain");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_PINNEDPUBLICKEY, "sha256//$hash");
$sslCertificate = curl_exec($ch);
curl_close($ch);
echo "<pre>";
echo empty($sslCertificate) ? "Failure" : "Success";
echo "</pre>";
?>
 

Output

$ /usr/bin/php cert_pin.php
<pre>Success</pre>