How to send a curl request with pem certificate via PHP? How to send a curl request with pem certificate via PHP? apache apache

How to send a curl request with pem certificate via PHP?


I think that you need to use the tmpfile() and stream_get_meta_data.

$pemFile = tmpfile();fwrite($pemFile, "test.pem");//the path for the pem file$tempPemPath = stream_get_meta_data($pemFile);$tempPemPath = $tempPemPath['uri'];curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath); 

Source: This answer here in SO helps me with similar problem.


I think you're missing curl_setopt($ch, CURLOPT_CAINFO, 'test.pem');Have a look at cURL is unable to use client certificate , in local serverfor more about using client certificates in curl via PHP