我有四个客户端提供的文件 .
-
test.jks
-
test.pem
-
key.pub
-
test.p12
我必须使用curl在这个url上发送json数组 . 所以我很困惑其他文件的用途是什么?像.p12,.jks . 以上文件的关键是什么?我开始使用此链接包含.pem文件:How to send a curl request with pem certificate via PHP?
所以,我得到了以下错误 .
错误:
卷曲错误:无法加载PEM客户端证书,OpenSSL错误错误:0906D06C:PEM例程:PEM_read_bio:没有开始行,(找不到密钥,错误的密码短语或错误的文件格式?)没有返回HTTP代码
代码:
$url = "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$pemFile = tmpfile();
fwrite($pemFile, "test.pem");//the path for the pem file
$tempPemPath = stream_get_meta_data($pemFile);
$tempPemPath = $tempPemPath['uri'];
curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath);
//curl_setopt($ch, CURLOPT_SSLCERT, "test.pem" );
curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result = curl_exec($ch);
if(!$result)
{
echo "Curl Error: " . curl_error($ch);
}
else
{
echo "Success: ". $result;
}
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
if (empty($info['http_code'])) {
die("No HTTP code was returned");
} else {
// load the HTTP codes
$http_codes = parse_ini_file("path/to/the/ini/file/I/pasted/above");
// echo results
echo "The server responded:
";
echo $info['http_code'] . " " . $http_codes[$info['http_code']];
}