PHP Classes

How to check server certificate validity

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  How to check server certificate validity  >  (Un) Subscribe thread alerts  
Subject:How to check server certificate validity
Summary:How to check server certificate validity
Messages:5
Author:Nicola Mosca
Date:2007-03-19 13:57:43
Update:2007-03-21 19:59:03
 

  1. How to check server certificate validity   Reply   Report abuse  
Picture of Nicola Mosca Nicola Mosca - 2007-03-19 13:57:44
Is it possible to edit httpclass to check the SERVER certificate validity?

I'm taking a look at www.php.net/openssl but, how can i retrieve the server certificate to check it?

Can i retrieve it from a socket?

Thanks in advance

  2. Re: How to check server certificate validity   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-03-19 14:16:45 - In reply to message 1 from Nicola Mosca
Good question. I am not sure, but I don't think there is a way to enforce remote certificate validity when using fsockopen.

You can do that when using curl functions. If it is important for you, I can force using curl functions when certificate validation is required.

  3. Re: How to check server certificate validity   Reply   Report abuse  
Picture of Nicola Mosca Nicola Mosca - 2007-03-20 07:43:14 - In reply to message 2 from Manuel Lemos
If you want i can try to edit your class and then send you my changes...

If i've correctly understand, i have to set up a certification authority for curl and then tell curl to don't estabilish connection with peers that aren't correctly certified, is it correct?

  4. Re: How to check server certificate validity   Reply   Report abuse  
Picture of Nicola Mosca Nicola Mosca - 2007-03-21 19:20:52 - In reply to message 3 from Nicola Mosca
Here there are my changes, in the method Open near the line 500

if(IsSet($arguments["SSLCaInfo"])){
curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($this->connection,CURLOPT_CAINFO,$arguments["SSLCaInfo"]);
}

if(IsSet($arguments["SSLCaPath"])){
curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($this->connection,CURLOPT_CAPATH,$arguments["SSLCaPath"]);
}

It check's the certificate, but it doesn't abort the connection...this is the debug output:

* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.

Why continuing anyway?
How can i force curl to abort the connection if the SSL certificate verify result isn't certified?


  5. Re: How to check server certificate validity   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-03-21 19:59:03 - In reply to message 4 from Nicola Mosca
I suspect that you just need to specify to verify peer. Curl can only verify a peer if it has a certificate of the certification authority that issued the remote site certificate.

As for continuing the request anyway, that is silly. Maybe there is an option to make it abort the request in that case.