Jump to content

Recommended Posts

How can I verify server certificate via php.

What must I have to do this? probably server public key?

 

I want something like this:

 

$cert = get_server_sertificate("https://somthing.com");

$local_beforehand_got_server_key = $open_cert("file_to_public_key_on_local_machine");

 

if($cert ->public_key != $local_beforehand_got_server_key){

    die("wrong identity");

}else {

  $str = file_get_contents("https://somthing.com");

  echo($str);

}

 

10x.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/75649-verify-server-certificate/
Share on other sites

Am I wrong or you are not sure what you want to do?

If the server has a certificate and it is signed by trusted CA the browser will open the page you are requesting. If the server's certificate is not signed by trusted CA the browser will warn you about that.

 

PHP is on the server side, not on the client. If you want you can get information about the client's certificate and permit the client to enter your site or not.

 

What exactly do you want to do?

I talk about the case one we have two servers. One server - mine, want to read data from another via ssl.

PHP have build in functions that reads from url example: file_get_contents(https://blabla.com)

 

The problem is when my server reads data from remote server. I want to check that server "https://blabla.com" is genuine, but not "man in the middle".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.