cURL error 60: SSL certificate problem: unable to get local issuer certificate (see…
- User
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx03135b102ca72d&secret=111
- Assistant
The cURL error 60 is a common issue that developers encounter when making HTTPS requests using cURL in PHP or other programming environments. This error occurs because cURL cannot verify the SSL certificate of the server it is trying to communicate with. The message "SSL certificate problem: unable to get local issuer certificate" indicates that the root certificate or the chain of certificates used by the server isn't recognized by your local server or development environment.
Here’s how you can resolve this issue:
1. Download CA Certificates
First, you need a file with the latest CA (Certificate Authorities) certificates. You can download this file from the official cURL website or the Mozilla project, which is often used since it's regularly updated.
- Go to the cURL CA Extract page or the Mozilla Included CA Certificate List to download the latest
cacert.pemfile.
2. Update php.ini Configuration
Once you have the
cacert.pemfile, you need to configure PHP to use it for SSL requests. This involves updating thephp.inifile.-
Locate your
php.inifile. (Its location depends on your server setup. If you’re using XAMPP, it’s typically found in thephpfolder.) -
Open
php.iniin a text editor. -
Search for
curl.cainfoandopenssl.cafiledirectives. They may be commented out by default (preceded by a;). -
Update these directives with the path to your downloaded
cacert.pemfile. It should look something like this:curl.cainfo = "C:\path\to\cacert.pem" openssl.cafile = "C:\path\to\cacert.pem"Make sure to replace
C:\path\towith the actual path where you’ve placed thecacert.pemfile. -
Save the
php.inifile and restart your web server for the changes to take effect.
3. Verify or Update cURL Command (Optional)
If you are manually running a cURL command in the terminal or a script and encounter this problem, you can specify the CA bundle to be used:
curl --cacert /path/to/cacert.pem https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx03135b102ca72d&secret=111Troubleshooting
- Ensure the path to
cacert.peminphp.iniis correct. - Make sure to restart your web server or PHP-FPM service after making changes to
php.ini. - If using a shared hosting, you may need to contact your hosting provider for assistance with updating CA certificates.
Security Note
It's important to keep the
cacert.pemfile updated to ensure you have the latest CA certificates for verifying SSL connections. Additionally, avoid disabling SSL verification in your cURL requests as this compromises the security of data transmission. - Go to the cURL CA Extract page or the Mozilla Included CA Certificate List to download the latest