I have a script that needs to use cURL to securely connect to a web site, foo.bar.com that is covered by a wildcard SSL certificate for *.bar.com.
The wildcard certificate is issued by Verisign, and all browsers trust it without any problem. However, I cannot get PHP / cURL to connect (at least not without disabling certificate verification).
Just for the sake of isolating the problem, I tried to connect using just command-line cURL (version 7.21.1). I downloaded an updated CA bundle from Mozilla (saved as cacert.pem), and then ran:
curl --cacert /path/to/cacert.pem "https://foo.bar.com"
The result was:
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.
I've been Googling and reading post after post about this error, but can't seem to get anywhere.
If I try any normal, non-wildcard-certificate domain, it seems to work just fine, so it seems localized to this particular wildcard certificate issue. I've even manually exported all the certificates in the trust chain and manually added them into the cacert.pem file (just to see if the CA bundle was missing something), and still nothing.
Ultimately, I want to get this working in PHP cURL, but I figure if I can determine the problem with command-line cURL, the solution will probably apply to the PHP script, as well.
The problem is probably not curl but an incomplete trust chain because of missing chain certificates. Desktop browsers have less problems with this because they cache such certificates when visiting other sites and some browsers even download missing certificates.
Header over to SSLLabs and check the site. Look out for "Chain Issues".
If my answer is wrong please add the relevant URL and also the version of curl you use, so that one can have a closer look.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With