是否可以从任何网站读取PHP中的SSL信息? [英] Is it possible to read SSL information in PHP from any website?

查看:132
本文介绍了是否可以从任何网站读取PHP中的SSL信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能使用PHP从其他方读取关于他们的SSL证书信息的信息,我试图找到它的年龄,但没有找到我的真正的答案。

例如,我在脚本中输入www.paypal.com,它将返回以下内容:




  • 权限:VeriSign,Inc

  • 到期日:2011年2月18日(18/02/11)

  • 类型: li>
  • Host: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])));
?>


I want to know is it possible to read information from other parties using PHP about their SSL certificate information, I've tried to find about it for ages but there's no real answer that has been found for me.

For example, I input "www.paypal.com" into the script and it will return the following:

  • Authority: VeriSign, Inc
  • Expires: 18th February 2011 (18/02/11)
  • Type: Extended Validation
  • Host: www.paypal.com
  • MD5: a8e7o7a8e9e9
  • SHA1: c2a4a1e4e3a2

And, whatever else is possible to obtain. I would like the script in PHP please.

解决方案

<?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"]) );
?>

这篇关于是否可以从任何网站读取PHP中的SSL信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆