private static function calculateX509Fingerprint($pem, $algorithm, $binary = false) { $pem = preg_replace('#-.*-|\\r|\\n#', '', $pem); $bin = base64_decode($pem); return hash($algorithm, $bin, $binary); }