views:

29

answers:

2

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.

+1  A: 

PHP's OpenSSL functions like openssl_x509_parse should help you out.

stillstanding
How would I build it to read from a site's SSL information? I don't know how to obtain SSL information from a third party website.
WebEntrepreneur
A: 
<?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"]) );
?>
velcrow
src: http://stackoverflow.com/questions/3081042/how-to-get-ssl-certificate-info-with-curl-in-php/3081093
velcrow