我想知道是否可以使用 PHP 从其他方读取有关其 SSL 证书信息的信息,我多年来一直试图找到它,但没有找到真正的答案。
例如,我在脚本中输入“www.paypal.com”,它将返回以下内容:
- 权威机构:威瑞信公司
- 过期日期:2011 年 2 月 18 日 (18/02/11)
- 类型:扩展验证
- 主办方:www.paypal.com
- MD5:a8e7o7a8e9e9
- SHA1:c2a4a1e4e3a2
并且,还有其他任何可能获得的东西。我想要 PHP 脚本。
<?php
$g = stream_context_create (array("ssl" => array("capture_peer_cert" => true)));
$r = stream_socket_client("ssl://www.google.com:443", $errno, $errstr, 30,
STREAM_CLIENT_CONNECT, $g);
$cont = stream_context_get_params($r);
print_r( openssl_x509_parse($cont["options"]["ssl"]["peer_certificate"]) );
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)