dongtiaobeng7901 2013-02-05 15:21
浏览 1016

cURL错误(58):无法设置私钥文件:'/ var / www / work / xml / keys / client.pem'类型PEM

I am getting this error, while connecting to a server using private and public keys.

cURL Error (58): unable to set private key file: '/var/www/work/xml/keys/client.pem' type PEM

My private keys contain both key and certificate. It has also password.

My current code is here:

    $url="https://example.website.com";

    $pemfile = "/var/www/work/xml/keys/server.pem";
    $keyfile = "/var/www/work/xml/keys/client.pem";

    $requestXml = file_get_contents("net.xml");

    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HTTP_VERSION, 1.1); 
    curl_setopt($ch, CURLOPT_PORT, 443); 
    curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);

    curl_setopt($ch, CURLOPT_VERBOSE, 1); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 

    curl_setopt($ch, CURLOPT_FAILONERROR, 0); 

    curl_setopt($ch, CURLOPT_SSLCERT, $pemfile); 
    curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM'); 
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'PASSWORD'); 


    curl_setopt($ch, CURLOPT_SSLKEY, $keyfile); 
    curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "PASSWORD");


    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXml);

    $data = curl_exec($ch);
    $curl_errno = curl_errno($ch);
    $curl_error = curl_error($ch);

    if ($curl_errno > 0) 
    {
        echo "cURL Error ($curl_errno): $curl_error
";
    }
    else 
    {
        header("Content-Type: text/xml");
        print_r($data);
    }

    curl_close($ch);
  • 写回答

1条回答 默认 最新

  • dsfadsa08911 2013-02-05 15:31
    关注

    it appears your script can not access the $keyfile file correctly. you may want to double-check that your script (or process) has the correct privileges, or modify the file permissions.

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容