To authenticate web clients using a browser is no difficulty when one has imported the PKI certificate in the browser.
But how can we do that with a php driven process and use it as client. Here is some short PHP code that will do exactly that.
Note: the CA, PKI certificate(CRT) and private key(KEY) files must be in PEM format for this to work.
<?php
$ch = curl_init('https://my.example.net/private');
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSLCERT, "/etc/ssl/certs/example_CRT.pem");
curl_setopt($ch, CURLOPT_SSLKEY, "/etc/ssl/certs/example_KEY.pem");
curl_setopt($ch, CURLOPT_CAINFO, "/etc/ssl/certs/example_CA.pem");
$output = curl_exec($ch);
$response = curl_getinfo($ch);
curl_close($ch);
var_dump ($response);
var_dump ($output);
?>