Home > Backend Development > PHP Tutorial > How to Resolve Curl Error 60: Self-Signed SSL Certificate Issues?

How to Resolve Curl Error 60: Self-Signed SSL Certificate Issues?

Mary-Kate Olsen
Release: 2024-12-07 18:15:13
Original
751 people have browsed it

How to Resolve Curl Error 60: Self-Signed SSL Certificate Issues?

Fixing Curl Error 60: SSL Certificate Issue with Self-Signed Certificates

When making a curl request to a secure website using a self-signed SSL certificate, an error message "Curl error 60: SSL certificate problem: self signed certificate in certificate chain" might appear. This error indicates that cURL is unable to validate the server's SSL certificate, potentially due to an outdated certificate bundle.

Solution:

  1. Obtain and Install an Updated CA Root Certificate Bundle

    Download the latest bundle of CA root certificates from http://curl.haxx.se/docs/caextract.html and install it in the appropriate location specified in PHP's php.ini file:

    curl.cainfo = <absolute_path_to> cacert.pem
    Copy after login
  2. Set CURLOPT_CAINFO Option

    During runtime, set the CURLOPT_CAINFO option for the curl resource to the full path of the installed certificate bundle:

    curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
    Copy after login

These steps will update cURL's certificate validation mechanism and allow it to accept self-signed SSL certificates, resolving the Curl error 60.

Note:

It's crucial to use and maintain an up-to-date CA root certificate bundle for secure cURL communication. Avoid disabling SSL certificate verification, as it compromises the security of your requests.

The above is the detailed content of How to Resolve Curl Error 60: Self-Signed SSL Certificate Issues?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template