Error using PHP cURL with SSL certificates

前端 未结 5 1800
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 10:03

I\'m trying to write a PHP script using cURL that can authorize a user through a page that uses an SSL certificate, in addition to username and password, and I can\'t seem t

5条回答
  •  孤城傲影
    2020-12-08 10:47

    After 6 years of the question, I meet the same problem on a shared-host, and apparently there is no satisfactory answer. I found for myself a solution, hope it useful for everybody.

    You can try this config:

    curl_setopt($config,CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($config,CURLOPT_SSL_VERIFYPEER,1);
    curl_setopt($config,CURLOPT_CAINFO,'ca-bundle.crt');
    curl_setopt($config,CURLOPT_CAPATH,'ca-bundle.crt');
    

    I met same error with @Magsol: Error: error setting certificate verify locations: CAfile: /path/to/servercert.cer CApath: none; so I added the 4th line to set CAPath.

    It's work with me. But note, the CA file must be place in accessable dir (with chmod 755 or 777) and it will better if CA file is in the same dir with PHP file.

提交回复
热议问题