Error using PHP cURL with SSL certificates

前端 未结 5 1804
伪装坚强ぢ
伪装坚强ぢ 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 11:02

    You can try this if it works for you:

    curl_setopt($ch, CURLOPT_URL, "https://test.example.com/v1/authenticate.json?api_key=123456");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch,CURLOPT_CAINFO,'cert.embedapp.20191004.pem');
    curl_setopt($ch,CURLOPT_CAPATH,'./cert.embedapp.20191004.pem');
    

    Comment these lines and add this:

    //curl_setopt($ch,CURLOPT_CAINFO,'cert.embedapp.20191004.pem');
    //curl_setopt($ch,CURLOPT_CAPATH,'./cert.embedapp.20191004.pem');
    curl_setopt($ch, CURLOPT_SSLCERT,'cert.embedapp.20191004.pem');
    

提交回复
热议问题