我需要通过证书和密钥将JsonData发送到其他ABC系统API,但我总是收到错误消息:卷曲错误:无法使用客户端证书(找不到密钥或错误的密码短语?)
当我从ABC系统检查时,没有收到任何数据,我是否知道有什么可能会返回此错误?
有没有人可以帮我检查我的代码,我的证书和密码确认是正确的
function sendJsonDataToSSL_API2($https_url, $jsonData) {
//base_url() .
$crtFile = 'http://www.example.com/certificate.crt';
$pemfile = 'http://www.example.com/certificate.pem';
$keyfile = 'http://www.example.com/privatekey.key';
$cert_password = 'abcd1234';
$url = $https_url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_SSLCERT, $pemfile);
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
curl_setopt($ch, CURLOPT_SSLKEY, $keyfile);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $cert_password);
curl_setopt($ch, CURLOPT_CAINFO, $crtFile);
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $cert_password);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$output = curl_exec($ch);
if ($output === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
//echo 'Operation completed without any errors';
}
return $output;
}