Troubleshooting Ignored CURLOPT_SSL_VERIFYPEER in PHP CURL
Problem:
Users are encountering an issue where HTTPS requests using CURL raise a "Problem with the SSL CA cert" error, despite setting both CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to false.
Causes and Solutions:
To successfully verify host or peer certificates using CURL, you need to specify alternate certificates with CURLOPT_CAINFO or a certificate directory with CURLOPT_CAPATH.
Additionally:
CURLOPT_SSL_VERIFYHOST:
Suggested Code:
To disable verification for host and peer:
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
To enable verification and specify a CA certificate file:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");
Additional Notes:
Update:
After updating libraries and restarting the system, the issue may resolve itself.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3