I used below code in PHP. I searched few sites and worked this below curl function. In Postman Add Certificate (Settings->SSL Verification Settings) it is working by passing CRT,PEM,PFX and Passphrase. But when I'm going to use this in PHP code it is not working.
function curlapi() {
$url = "https://exampleurl.com/service";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Content-Type: application/json",
);
$data = '{"login":"test_login","password":"test_password"}';
$pemFile = tmpfile();
fwrite($pemFile, "/folder/path/test_file.pem");//the path for the pem file
$tempPemPath = stream_get_meta_data($pemFile);
$tempPemPath_uri = $tempPemPath['uri'];
curl_setopt($curl, CURLOPT_SSLCERT, $tempPemPath_uri);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
echo "<pre>";
print_r(curl_getinfo($curl)) . '<br/>';
echo curl_errno($curl) . '<br/>';
echo curl_error($curl) . '<br/>';
curl_close($curl);
print_r($resp);
exit;
}
curlapi();
Finally, for my concern there is no usage of CRT, PFX & Passphrase in CURL request. It works only with PEM file path.