When you try to run json_decode on https, it will throw errors due to null value. file_get_contents("php://input") will also return null.
Way to solve it and the most efficient are as follows
//get data from caller
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$your_data_array= json_decode(file_get_contents("php://input",false, stream_context_create($arrContextOptions)),true);
The code actually make it don't care what protocol you are using and set it to false (means no verifications). It normally happen when you are using self-signed or non-standard SSL certificates.
It is the most efficient and the fastest solutions.. but not the most practical :)
The best is -> use standard approved certificates :)
Tuesday, December 20, 2016
Home »
PHP
,
Software Security
,
Tips and Trick
,
Web-based application
» json_decode(file_get_contents("php://input") on https
2 comments:
Nice Information thank you for Sharing useful information. Great job.
App developer Malaysia
Thanks for an insightful post.These tips are really helpful. Thanks a lot.Keep it up.Keep blogging.!!
app developer malaysia!
Post a Comment