cURL PHP Proper SSL between private servers with self-signed certificate -


i had connection between 2 servers running curlopt_ssl_verifypeer set "false" no common name in ssl cert avoid errors. following client code connected server certificate:

curl_setopt($ch,curlopt_ssl_verifypeer,false); curl_setopt($ch,curlopt_ssl_verifyhost,2); 

however, changed code (set true) , specified computers certificate in pem format.

curl_setopt($ch,curlopt_ssl_verifypeer,true); curl_setopt($ch,curlopt_ssl_verifyhost,2); curl_setopt($ch,curlopt_cainfo,getcwd().'/includes/hostcert/hostname.crt'); 

this worked great on local network test machine, certificate signed it's hostname cn. how can setup php code trusts hostname computer , maintains secure connection.

i'm aware can set curlopt_ssl_verifyhost "0" or "1" , curlopt_ssl_verifypeer "false", these not valid solutions break ssl security.

my /etc/hosts file follows:

#<ip-address>   <hostname.domain.org>   <hostname> 127.0.0.1       localhost.localdomain   localhost examplehostname ::1             localhost.localdomain   localhost 

you need generate certificate valid host name, as requested client. if you've used machine.local internal name, want use external clients calling via machine.example.org, need certificate use valid machine.example.org.

if need both (since same machine may called different host names), use subject alternative name extension , put multiple dns entries in certificate.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -