6
A
回答
1
我猜最简单的方法将是通过系统
$fingerprint = str_replace("SHA1 Fingerprint=", '', system('openssl x509 -noout -in /path/to/your/cert.pem -fingerprint'));
调用OpenSSL和是的,我知道,这是没有像这样做的干净的方式 - 但是,它是唯一一个我能想到我的头顶!
13
我想你可以生成SHA指纹用下面的代码:
$resource = openssl_x509_read($certificate);
$fingerprint = null;
$output = null;
$result = openssl_x509_export($resource, $output);
if($result !== false) {
$output = str_replace('-----BEGIN CERTIFICATE-----', '', $output);
$output = str_replace('-----END CERTIFICATE-----', '', $output);
$output = base64_decode($output);
$fingerprint = sha1($output);
}
+0
非常适合我,谢谢。 –
4
这里是一个更好的解决方案:
function sha1_thumbprint($file)
{
$file = preg_replace('/\-+BEGIN CERTIFICATE\-+/','',$file);
$file = preg_replace('/\-+END CERTIFICATE\-+/','',$file);
$file = trim($file);
$file = str_replace(array("\n\r","\n","\r"), '', $file);
$bin = base64_decode($file);
return sha1($bin);
}
0
1
从PHP 5.6起,您可以使用openssl_x509_fingerprint()
:
$cert = openssl_x509_read($certificate);
$sha1_hash = openssl_x509_fingerprint($cert); // sha1 hash
$md5_hash = openssl_x509_fingerprint($cert, 'md5'); // md5 hash
这个功能目前无证,但是这将固定在释放时间;这是函数签名:
openssl_x509_fingerprint($cert [, $hash_method = "sha1" [, $raw_output = false ] ])
相关问题
- 1. 在C中打开SSL证书指纹
- 2. SSL通配符证书指纹
- 3. 通过比较证书指纹进行SSL身份验证?
- 4. PHP CURL和SSL证书(或证书链)
- 5. 从powershell中的目录获取ssl证书指纹
- 6. fetchmail:获得ssl证书和指纹检查的好处
- 7. PHP SVN - SSL证书错误
- 8. PHP SSL证书摘要
- 9. curl ssl证书
- 10. SSL证书认证
- 11. 无法通过指纹找到证书
- 12. 拉的变化:bitbucket.org证书指纹SSH
- 13. Smartgit证书的SHA指纹不匹配
- 14. Android MD5 SDK指纹调试证书
- 15. 从签名证书指纹创建SecurityKey
- 16. 如何获取SHA256证书指纹?
- 17. keytool和openssl证书指纹不匹配
- 18. 证书指纹出口后不匹配
- 19. Android SSL证书
- 20. Nodejitsu SSL证书
- 21. box.com ssl证书
- 22. Cloudflare SSL证书
- 23. CherryPy ssl证书
- 24. SSL证书
- 25. SSL证书
- 26. CNAME SSL证书
- 27. jboss ssl证书
- 28. Umbraco - SSL证书
- 29. HWIOAuthBundle - SSL证书
- 30. SSL证书Socket.io
恐怕如果使用system或exec - works会依赖于OS。为此,我尝试仅使用OpenSSL的PHP函数 –