简体   繁体   English

PHP cURL错误58

[英]PHP cURL error 58

Need some help understanding the ubiquitous cURL 58 error, which is due to, in this case, including a PEM file with the cURL request. 需要一些帮助来理解普遍存在的cURL 58错误,在这种情况下,这是由于包含带有cURL请求的PEM文件所致。

 Error 58: unable to set private key file

My code can successfully open the .pem file (see fopen() call) but cURL complains that it cannot set the private key file. 我的代码可以成功打开.pem文件(请参阅fopen()调用),但是cURL抱怨它无法设置私钥文件。 Trying to better understand if this something on the client end (me) or something being returned from the host. 试图更好地了解这是客户端(me)上的内容还是主机返回的内容。 Pretty sure it's on my end but not sure what. 可以肯定,这是我的最终目的,但不确定。

Thanks 谢谢

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->apiURL);
$fh = fopen($this->certPath,'a+');

if($fh){
         echo "File opened!";
         fclose($fh);
       } else {
         echo "File not opened";
}

    curl_setopt($ch, CURLOPT_SSLCERT, $this->certPath);
    curl_setopt($ch, CURLOPT_POSTFIELDS, trim($SOAPrequest));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    if (curl_error($ch)) {
        printf("Error %s: %s", curl_errno($ch), curl_error($ch));
    }
    curl_close ($ch);

    return $result;
}

The key: 钥匙:

-----BEGIN CERTIFICATE-----
MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB
yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL
[...]
-----END CERTIFICATE-----

Your file does not contain any private key, only public key. 您的文件不包含任何私钥,仅包含公钥。
I think you probably have no reason to use CURLOPT_SSLCERT at all. 我认为您可能根本没有理由使用CURLOPT_SSLCERT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM