Pari
Pari

Reputation: 333

PHP program for SSL certificate validation

I'm working on Boss Linux OS. I'm trying to work out how to validate a SSL certificate and also retrieve the SSL/TLS version used, cipher used and the algorithm (SHA, MD5..), expiry date of the certificate used by the site passed as parameter

openssl s_client -connect www.google.com:443

using this command helps me view the certificate of www.google.com. Now from that output i need to extract the SSL/TLS version used by them, cipher used, algorithm used, expiry date of the certificate and so on... I need to write a PHP program to extract those values.

Upvotes: 2

Views: 2184

Answers (2)

mac
mac

Reputation: 21

You don't need cain or whatever...!!

For the cipher you can simply use the openssl x509 -in file.crt -help

Also I wouldn't use the system() call for executing a form input :) You are better off using openssl_ functions that are built into php!

Upvotes: 1

ionFish
ionFish

Reputation: 1024

If you're familiar with OpenSSl, http://php.net/manual/en/book.openssl.php, then you might be able to make a very small PHP file like so:

<?php
echo '<pre>';
passthru("openssl [parameters] $certificate");
echo '</pre>';
?>

Variable $certificate is collected by a simple form (upload form perhaps?) so you can analyze a raw certificate file.

Could you though, maybe provide more information on the type of SSL certificate?

You're not going to be able to figure out the cipher very easily, it will take something like Cain and Abel and a powerful processor, and lots of time.

Upvotes: 1

Related Questions