Home > Backend Development > PHP Tutorial > How to Fix cURL Error 60: SSL Certificate Problems?

How to Fix cURL Error 60: SSL Certificate Problems?

Mary-Kate Olsen
Release: 2024-11-28 05:21:16
Original
1009 people have browsed it

How to Fix cURL Error 60: SSL Certificate Problems?

Curl Error 60: SSL Certificate Issue

When attempting to use cURL to send a request to a URL that requires SSL, an error message indicating a "self-signed certificate in certificate chain" may be encountered.

This error occurs because cURL is unable to verify the SSL certificate presented by the remote server. This can happen if the certificate is self-signed, meaning it is not issued by a trusted certificate authority (CA).

To resolve this issue, you can manually disable cURL's SSL certificate verification. However, this is not recommended as it can compromise the security of your application.

Instead, you should ensure that the PHP installation used by cURL has a valid bundle of CA root certificates. This bundle is used by cURL to verify the authenticity of the server's SSL certificate.

You can download an up-to-date CA root certificate bundle from here: http://curl.haxx.se/docs/caextract.html

Once downloaded, configure PHP to use the bundle by setting the curl.cainfo option in php.ini to the absolute path of the certificate file.

curl.cainfo = <absolute_path_to>/cacert.pem
Copy after login

Alternatively, you can configure the CA certificate at runtime using the CURLOPT_CAINFO option:

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

By providing a valid CA root certificate bundle, cURL will be able to verify the server's SSL certificate and establish a secure connection.

The above is the detailed content of How to Fix cURL Error 60: SSL Certificate Problems?. 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