php - Code does not work without disabling SSL -


please take @ code:

<?php $url = "the_source_url";   $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_ssl_verifypeer, false); $result = curl_exec($ch); print_r($result); ?> 

this page accessed android app date source. url returns json data, print back, then, in app, process data , display it. working fine me right (i'm still in testing phase).

i read in disabling ssl (whih did in line 6) risky , not recommended. however, couldn't make script work unless disable it.

how make work without disabling ssl? or how eliminate risk?

disabling certificate make vulnerable man in middle attack, can download use certificate

curl_setopt ($ch, curlopt_ssl_verifypeer, true); curl_setopt($ch, curlopt_ssl_verifyhost, 2); curl_setopt ($ch, curlopt_cainfo, "path_to_certificate/cert.pem"); 

to certificate follow guide

then click on “view certificate”:

enter image description here

bring “details” tab of cerficates page, , select certificate @ top of hierarchy. ca certificate.

enter image description here

then click “export”, , save ca certificate selected location, making sure select x.509 certificate (pem) save type/format.

enter image description here

image source : http://unitstep.net/


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -