Disabling CURLOPT_SSL_VERIFYPEER
PHP's CURL library offers options to verify SSL certificates during HTTPS requests. However, some users may encounter the issue where disabling verification using CURLOPT_SSL_VERIFYPEER seems ineffective. This arises after upgrading CURL libraries.
Troubleshoot and Solutions
To resolve this issue, consider the following measures:
-
Verify Certificate Paths: Ensure that the paths provided for CA certificates (using CURLOPT_CAINFO and CURLOPT_CAPATH) are correct and accessible by the server.
-
Set CURLOPT_SSL_VERIFYHOST to 0: This option checks the existence of a common name in the SSL peer certificate. Setting it to 0 disables host verification.
-
Restart Apache After Library Update: After updating CURL libraries, restart the Apache server to ensure the changes take effect.
-
Disable CURLOPT_SSL_VERIFYPEER in php.ini: Add curl.cainfo=/path/to/certificate.pem to the php.ini file to disable verification system-wide.
-
Disable Verification for the Session: Set CURLOPT_SSL_VERIFYPEER to 0 for the specific CURL session to disable verification.
Additional Considerations
- Disabling SSL verification compromises security. Use this option only if absolutely necessary.
- If the server certificate is invalid or untrustworthy, verifying it may result in errors.
- CURLOPT_CAPATH allows specifying a directory containing multiple CA certificates.
By following these steps, you should successfully disable CURLOPT_SSL_VERIFYPEER and perform HTTPS requests without encountering SSL certificate errors.
The above is the detailed content of Why Is Disabling CURLOPT_SSL_VERIFYPEER Ineffective After Upgrading CURL Libraries?. For more information, please follow other related articles on the PHP Chinese website!