2017-08-02 20 views
2

私は証明書を持っており、ファイルパスからSHA 1 FingerprintSHA 256 Fingerprintを読みたいと思います。PHPのパスから証明書のサムプリントを読み取る方法

<?php 

ini_set("display_startup_errors", 1); 
ini_set("display_errors", 1); 
error_reporting(-1); 

$certificate = "./wwwbbminfocom.crt"; 
$cert = openssl_x509_read($certificate); 
$sha1_hash = openssl_x509_fingerprint($cert); // sha1 hash 
$md5_hash = openssl_x509_fingerprint($cert, 'md5'); // md5 hash 

?> 

注:

Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in /home/super/public_html/md.php on line 8 

Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in /home/super/public_html/md.php on line 9 

Warning: openssl_x509_fingerprint(): cannot get cert from parameter 1 in /home/super/public_html/md.php on line 10 

親切にファイルを読み込み、指紋を取得する方法を私を助ける:私は、次のPHPの警告を得たウェブサイトからhttps://www.bbminfo.com/Tutor/php_error_error_log.php

をSSL証明書をダウンロードしました。私は使用していますPHP 7.0

+0

てみてください: '$ CERT = openssl_x509_read(のfile_get_contents($証明書));' –

+0

@MagnusErikssonを - どうもありがとう...そのワーキング... –

答えて

0

OpenSSL関数に渡されるファイルパスは、完全修飾URLである必要があります。ローカルファイルシステムの場合、それはfile://absolute/path/to/file形式であることを意味します。

またはあなたの場合:もちろん

$certificate = "file://".realpath("./wwwbbminfocom.crt"); 

、コメントで提案されているように、あなたはまた、RAWファイルの内容を渡すことができますが、それは技術的にはそれほど効率的です。

はここまで読む:パスをotの代わりに、ファイルの内容を追加するhttps://secure.php.net/manual/en/openssl.certparams.php

関連する問題