WordPress has a function download_url that can download a file(such as an image) from remote site. I got this “cURL error 60: SSL certificate problem: certificate has expired” error when downloading from some sites. Apparently this is related to ssl certificate. Interestingly, I can download the file manually in a browser, and it does not complainĀ certificate error. I am calling this function as:
download_url(“https://myprogrammingnotes.com/test.png”)
The third parameter signature_verification of download_url is defaulted to false, which seems to mean it does not verification the certificate. But this is not true. In fact, WordPress will use the file http://yoursite.com/wp-includes/certificates/ca-bundle.crt to verify the certificate of myprogrammingnotes.com. And the error arises due to the outdatedĀ ca-bundle.crt.
The solution is to get the latest ca-bundle.crt to replace the outdated one. The fresh ca-bundle.crt can be downloaded from https://curl.se/ca/cacert.pem. Just rename the downloaded cacert.pem to ca-bundle.crt, and replace http://yoursite.com/wp-includes/certificates/ca-bundle.crt with it.
There is a WordPress plugin that can fix the error automatically so you do not need to update the certificate manually.
Reference:https://wordpress.org/support/topic/curl-error-60-ssl-certificate-problem-certificate-has-expired-9/