Bej
Bej

Reputation: 143

Curl certificate verification failed

I have installed the SSL certificates on my site and it is working in chrome and also in firefox. But whenever I perform curl with my site url, I am getting the below error.

* Connected to www.example.org port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 597 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
* Closing connection 0
curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
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 have seen many questions related to this and have tried them. I have tried updating the ca-certificates in my local and the error changed from local issuer verification to what it is now.

Can anyone suggest me where I am going worng?

Upvotes: 0

Views: 4908

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123531

Since you don't provide the URL to replicate the problem I can only speculate what the reason might be. But chances are high that your server is misconfigured and does not sent the required chain (intermediate) certificates, i.e. some chain certificate is missing. Desktop browsers often work around this issue but other clients will usually fail.

To verify my speculation check your site against SSLLabs and look out for reported chain issues.

Update: according to the comments of the OP at this question I was right. SSLLabs complained about "This server's certificate chain is incomplete" and also set the grade to B because of this.

Upvotes: 2

Related Questions