gpt4 book ai didi

php - curl 错误 : unable to set private key file: 'test.pem' type PEM

转载 作者:太空宇宙 更新时间:2023-11-03 13:23:50 27 4
gpt4 key购买 nike

我的 Pem 文件就是这种格式。

Bag Attributes
localKeyID:
friendlyName: test
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----

Bag Attributes
localKeyID:
friendlyName: test
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----

Bag Attributes
localKeyID:
friendlyName: test
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/emailAddress=operations@rightmove.co.uk
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,B9E036426B7AEDA6
-----END RSA PRIVATE KEY-----

我正在使用这段 PHP 代码。我收到这个错误。

Curl Error: unable to set private key file: 'test.pem' type PEM

代码。

   $json_data  // it's a json array.

$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, "test.pem");
curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/javascript'));
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: <br />";
echo $info['http_code'] . " " . $http_codes[$info['http_code']];
}

我在线检查证书解码器: https://www.sslshopper.com/certificate-decoder.html并且证书在此站点上有效。

所以这里的问题是什么我想不通。我也尝试使用 ssl 命令。

最佳答案

有两个错误。

  • 一个错误是 pem 文件,pem 文件生成有一个错误。
  • 另一个错误是我没有在代码中包含 CURLOPT_SSLCERTPASSWD()。

代码,

    curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM");
curl_setopt($ch, CURLOPT_SSLCERT, "test.pem");
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, '******'); // password

关于php - curl 错误 : unable to set private key file: 'test.pem' type PEM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39721352/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com