Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl cannot verify wildcard SSL certificate issued by Verisign

Tags:

php

curl

https

ssl

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.

like image 428
jhilgeman Avatar asked Mar 16 '23 19:03

jhilgeman


1 Answers

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.

like image 159
Steffen Ullrich Avatar answered Apr 25 '23 17:04

Steffen Ullrich