Sometimes we must use cert file to visit site or api.
If you only have .p12 file, please use openssl to rebuild a pem file.


$ch = curl_init();

curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_URL, 'https://api.xxxxx.com:443/');
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_SSLCERT, '/common/client.pem');
curl_setopt($ch,CURLOPT_CAINFO, '/common/server.cer');

curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($params));
$data = curl_exec($ch);
curl_close($ch);

var_dump($data);