卷曲错误:无法加载PEM客户端证书

我正在尝试使用证书通过PHP curl发送GET请求

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$pemFile = tmpfile();
fwrite($pemFile, "demo-cert.p12");//the path for the pem file
$tempPemPath = stream_get_meta_data($pemFile);
$tempPemPath = $tempPemPath['uri'];
curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath);
$result = curl_exec($ch);
if(!$result)
{
    echo "Curl Error: " . curl_error($ch);
}
else
{
    echo "Success: ". $result;
}

但是不知道如何通过“密码”,所以我得到这个错误

Curl Error: could not load PEM client certificate, OpenSSL error error:0906D06C:PEM 
routines:PEM_read_bio:no start line, (no key found, wrong pass phrase, or wrong file format?)

[更新]

将demo-cert.p12更改为与php文件一起存在的demo-cert.pem,但由于未发送密码而仍然遇到相同的问题。 证书文件夹包含其他2个文件:demo-combined.pem和demo-key.pem,但首先需要发送密码。

[更新2]

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSLCERT, 'demo-key.pem');
curl_setopt($ch, CURLOPT_SSLKEY, 'demo-cert.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'pass');
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'pass');

这些文件与PHP文件存储在同一目录中。 但仍然得到相同的错误

[更新 3]

如何编辑代码以发送服务器证书? curl-显示错误-详细--cacert服务器证书.pem-证书cert2.pem
curl_setopt($ch, CURLOPT_SSLCERT, 'demo-cert.pem');
curl_setopt($ch, CURLOPT_SSLKEY, 'demo-key.pem');

结果是:

Success: SOAP-ENV:ClientData required for operation

在浏览器中打开相同的URL时没有返回XML数据。错什么了吗?

First changed "CURLOPT_POST" from True to False. Second exchanged "CURLOPT_SSLCERT" value with "CURLOPT_SSLKEY" value to send the correct certificate and key file names Thanks to @vstm and now I get the correct result.

Thank you all.

Since you are using the filename - Try an absolute path. You don't need both the key and Cert to be converted to PEM. Just use the Single .PEM file that has both the certificate and key.

e.g

curl_setopt($ch, CURLOPT_SSLCERT, 'c:/wamp64/www/bit-tool/www/testcert.pem');