when trying to access endpoints of my self-hosted elasticsearch,
On Safari I get:
And on my client I get code: -67843, message: "The certificate was not trusted.
However when I request information from the //localhost:9200/_ssl/certificates endpoint on postman (which accepts invalid certs) I get an array full of certs:
[ { "path": "certs/http.p12", "format": "PKCS12", "alias": "http", "subject_dn": "CN=05eeab4fdxxx", "serial_number": "5126e9dc2658e8xxxxxxxxxxxxxxx", "has_private_key": true, "expiry": "2024-06-26T19:29:39.000Z" }, { "path": "certs/http.p12", "format": "PKCS12", "alias": "http", "subject_dn": "CN=Elasticsearch security auto-configuration HTTP CA", "serial_number": "ca270f5cdc32982970c192c6cxxxxxxxxxxxx", "has_private_key": false, "expiry": "2025-06-26T19:29:39.000Z" }, { "path": "certs/http.p12", "format": "PKCS12", "alias": "http_ca", "subject_dn": "CN=Elasticsearch security auto-configuration HTTP CA", "serial_number": "ca270f5cdc32982970c192c6c25xxxxxxxxxxxxxx", "has_private_key": true, "expiry": "2025-06-26T19:29:39.000Z" }, { "path": "certs/transport.p12", "format": "PKCS12", "alias": "transport", "subject_dn": "CN=Elasticsearch security auto-configuration HTTP CA", "serial_number": "19c5505398d30c56b0ea320exxxxxxxxxx", "has_private_key": false, "expiry": "2121-06-03T19:29:36.000Z" }, { "path": "certs/transport.p12", "format": "PKCS12", "alias": "transport", "subject_dn": "CN=05eeab4fd435", "serial_number": "eb743df4612a20b23d3exxxxxxxxxxxx", "has_private_key": true, "expiry": "2121-06-03T19:29:38.000Z" }, { "path": "certs/transport.p12", "format": "PKCS12", "alias": "transport_ca", "subject_dn": "CN=Elasticsearch security auto-configuration HTTP CA", "serial_number": "19c5505398d30c56b0eaxxxxxxxxxxxx", "has_private_key": false, "expiry": "2121-06-03T19:29:36.000Z" } ]Meaning I do have SSL certs up and running, I would guess. So how can I solve this problem?
- Home
- curl: (60) SSL certificate problem: unable to get local issuer certificate
909 votes
30 answers
[email protected]:/home/sclr/certs/FreshCerts# curl --ftp-ssl --verbose ftp://{abc}/ -u trup:trup --cacert /etc/ssl/certs/ca-certificates.crt * About to connect() to {abc} port 21 (#0) * Trying {abc}... * Connected to {abc} ({abc}) port 21 (#0) < 220-Cerberus FTP Server - Home Edition < 220-This is the UNLICENSED Home Edition and may be used for home, personal use only < 220-Welcome to Cerberus FTP Server < 220 Created by Cerberus, LLC > AUTH SSL < 234 Authentication method accepted * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS alert, Server hello (2): * SSL certificate problem: unable to get local issuer certificate * Closing connection 0 curl: (60) SSL certificate problem: unable to get local issuer certificate More details here: //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.
2021-11-26
798
votes
Answer
Solution:
Relating to 'SSL certificate problem: unable to get local issuer certificate' error. It is important to note that this applies to the system sending the CURL request, and NOT the server receiving the request.
Download the latest cacert.pem from //curl.haxx.se/ca/cacert.pem
Add the '--cacert /path/to/cacert.pem' option to the curl command to tell curl where the local Certificate Authority file is.
(or) Create or add to a '.curlrc' file the line:cacert = /path/to/cacert.pem See 'man curl', the section about the '-K, --config <file>' section for information about where curl looks for this file.
(or if using php) Add the following line to php.ini: (if this is shared hosting and you don't have access to php.ini then you could add this to .user.ini in public_html).
curl.cainfo="/path/to/downloaded/cacert.pem"
Make sure you enclose the path within double quotation marks!!!
- (perhaps also for php) By default, the FastCGI process will parse new files every 300 seconds (if required you can change the frequency by adding a couple of files as suggested here //ss88.uk/blog/fast-cgi-and-user-ini-files-the-new-htaccess/).
Undefined answered
2021-11-26
Link to answer
558
votes
Answer
Solution:
It is failing as cURL is unable to verify the certificate provided by the server.
There are two options to get this to work:
Use cURL with-k option which allows curl to make insecure connections, that is cURL does not verify the certificate.
Add the root CA (the CA signing the server certificate) to/etc/ssl/certs/ca-certificates.crt
You should use option 2 as it's the option that ensures that you are connecting to secure FTP server.
Undefined answered
2021-11-26
Link to answer
676
votes
Answer
Solution:
I have solved this problem by adding one line code in cURL script:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);Warning: This makes the request absolute insecure (see answer by @YSU)!
Undefined answered
2021-11-26
Link to answer
632
votes
Answer
Solution:
For me, simple install of certificates helped:
sudo apt-get install ca-certificatesUndefined answered
2021-11-26
Link to answer
120
votes
Answer
Solution:
In my case it turned out to be a problem with the installation of my certificate on the service I was trying to consume with cURL. I failed to bundle/concatenate the intermediate and root certificates into my domain certificate. It wasn't obvious at first that this was the problem because Chrome worked it out and accepted the certificate in spite of leaving out the intermediate and root certificates.
After bundling the certificate, everything worked as expected. I bundled like this
$ cat intermediate.crt >> domain.crtAnd repeated for all intermediate and the root certificate.
Undefined answered
2021-11-26
Link to answer
601
votes
Answer
Solution:
Had this problem after install Git Extensions v3.48. Tried to install mysysgit again but same problem. At the end, had to disable (please consider security implications!) Git SSL verification with:
git config --global http.sslVerify falsebut if you have a domain certificate better add it to (Win7)
C:\Program Files (x86)\Git\bin\curl-ca-bundle.crtUndefined answered
2021-11-26
Link to answer
683
votes
Answer
Solution:
We ran into this error recently. Turns out it was related to the root cert not being installed in the CA store directory properly. I was using a curl command where I was specifying the CA dir directly.curl --cacert /etc/test/server.pem --capath /etc/test ... This command was failing every time with curl: (60) SSL certificate problem: unable to get local issuer certificate.
After usingstrace curl ..., it was determined that curl was looking for the root cert file with a name of 60ff2731.0, which is based on an openssl hash naming convetion. So I found this command to effectively import the root cert properly:
ln -s rootcert.pem `openssl x509 -hash -noout -in rootcert.pem`.0
which creates a softlink
60ff2731.0 -> rootcert.pem
curl, under the covers read the server.pem cert, determined the name of the root cert file (rootcert.pem), converted it to its hash name, then did an OS file lookup, but could not find it.
So, the takeaway is, use strace when running curl when the curl error is obscure (was a tremendous help), and then be sure to properly install the root cert using the openssl naming convention.
Undefined answered
2021-11-26
Link to answer
944
votes
Answer
Solution:
It is most likely a missing cert from the server.
Root->Intermediate->Server
A server should send the Server & Intermediate as a minimum.
Useopenssl s_client -showcerts -starttls ftp -crlf -connect abc:21 to debug the issue.
If only one cert is returned (either self signed, or issued), then you must choose to either:
- have the server fixed
- trust that cert and add it to your CA cert store (not the best idea)
- disable trust, e.g.curl -k (very bad idea)
If the server returned, more than one, but not including a self signed (root) cert:
- install the CA (root) cert in your CA store for the this chain, e.g. google the issuer. (ONLY if you trust that CA)
- have the server fixed to send the CA as part of the chain
- trust a cert in the chain
- disable trust
If the server returned a root CA certificate, then it is not in your CA store, your options are:
- Add (trust) it
- disable trust
I have ignored expired / revoked certs because there were no messages indicating it. But you can examine the certs withopenssl x509 -text
Given you are connecting to a home edition (//www.cerberusftp.com/support/help/installing-a-certificate/) ftp server, I am going to say it is self signed.
Please post more details, like the output from openssl.
Undefined answered
2021-11-26
Link to answer
888
votes
Answer
Solution:
According to cURL docs you can also pass the certificate to thecurl command:
Get a CA certificate that can verify the remote server and use the proper option to point out this CA cert for verification when connecting. Forlibcurl hackers:curl_easy_setopt(curl, CURLOPT_CAPATH, capath);
With the curl command line tool:--cacert [file]
For example:
curl --cacert mycertificate.cer -v //www.stackoverflow.comUndefined answered
2021-11-26
Link to answer
371
votes
Answer
Solution:
It might be sufficient to just update the list of certificates
sudo update-ca-certificates -fupdate-ca-certificates is a program that updates the directory /etc/ssl/certs to hold SSL certificates and generates ca-certificates.crt, a concatenated single-file list of certificates.
Undefined answered
2021-11-26
Link to answer
710
votes
Answer
Solution:
I have encountered this problem as well. I've read this thread and most of the answers are informative but overly complex to me. I'm not experienced in networking topics so this answer is for people like me.
In my case, this error was happening because I didn't include the intermediate and root certificates next to the certificate I was using in my application.
Here's what I got from the SSL certificate supplier:
- abc.crt - abc.pem - abc-bunde.crtIn theabc.crt file, there was only one certificate:
-----BEGIN CERTIFICATE----- /*certificate content here*/ -----END CERTIFICATE-----If I supplied it in this format, the browser would not show any errors (Firefox) but I would getcurl: (60) SSL certificate : unable to get local issuer certificate error when I did the curl request.
To fix this error, check yourabc-bunde.crt file. You will most likely see something like this:
-----BEGIN CERTIFICATE----- /*additional certificate content here*/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- /*other certificate content here*/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- /*different certificate content here*/ -----END CERTIFICATE-----These are your Intermediate and root certificates. Error is happening because they are missing in the SSL certificate you're supplying to your application.
To fix the error, combine the contents of both of these files in this format:
-----BEGIN CERTIFICATE----- /*certificate content here*/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- /*additional certificate content here*/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- /*other certificate content here*/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- /*different certificate content here*/ -----END CERTIFICATE-----Note that there are no spaces between certificates, at the end or at the start of the file. Once you supply this combined certificate to your application, your problem should be fixed.
Undefined answered
2021-11-26
Link to answer
906
votes
Answer
-----
Solution:
Download //curl.haxx.se/ca/cacert.pem
After download, move this file to your wamp server.
For exp: D:\wamp\bin\php\
Then add the following line to the php.ini file at the bottom.
curl.cainfo="D:\wamp\bin\php\cacert.pem"
- Now restart your wamp server.
Undefined answered
2021-11-26
Link to answer
543
votes
Answer
Solution:
Enter these two codes to disable the SSL certificate issue. it's worked for me after a lot of research I found this.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);Undefined answered
2021-11-26
Link to answer
389
votes
Answer
Solution:
Try reinstalling curl in Ubuntu, and updating my CA certs withsudo update-ca-certificates --fresh which updated the certs
Undefined answered
2021-11-26
Link to answer
393
votes
Answer
Solution:
Yes you need to add a CA certificate also. Adding a code snippet in Node.js for clear view.
var fs = require(fs) var path = require('path') var https = require('https') var port = process.env.PORT || 8080; var app = express(); https.createServer({ key: fs.readFileSync(path.join(__dirname, './path to your private key/privkey.pem')), cert: fs.readFileSync(path.join(__dirname, './path to your certificate/cert.pem')), ca: fs.readFileSync(path.join(__dirname, './path to your CA file/chain.pem'))}, app).listen(port)Undefined answered
2021-11-26
Link to answer
822
votes
Answer
Solution:
sudo apt-get install ca-certificatesWorked for me.
Undefined answered
2021-11-26
Link to answer
882
votes
Answer
Solution:
On windows I was having this problem. Curl was installed by mysysgit, so downloading and installing the newest version fixed my issue.
Otherwise these are decent instructions on how to update your CA cert that you could try.
Undefined answered
2021-11-26
Link to answer
619
votes
Answer
Solution:
My case was different. I'm hosting a site behind a firewall. The error was caused by pfSense.
Network layout: |Web Server 10.x.x.x| <-> |pfSense 49.x.x.x| <-> |Open InternetI accidentally found the cause, thanks to this answer.
All is well when I accessed my site from WAN.
However, when the site was accessed from inside LAN (e.g. when Wordpress made a|curl request to its own server, despite using the WAN IP49.x.x.x), it was served the pfSense login page.
I identified the certificate aspfSense webConfigurator Self-Signed Certificate. No wonder|curl threw an error.
Cause: What happened was that|curl was using the site's WAN IP address49.x.x.x. But, in the context of the web server, the WAN IP was the firewall.
Debug: I found that I was getting the pfSense certificate.
Solution: On the server hosting the site, point its own domain name to 127.0.0.1
By applying the solution,|curl's request was properly handled by the web server, and not forwarded to the firewall which responded by sending the login page.
Undefined answered
2021-11-26
Link to answer
300
votes
Answer
Solution:
You have to change server cert fromcert.pem tofullchain.pem
I had the same issue with Perl HTTPS Daemon:
I have changed:
SSL_cert_file => '/etc/letsencrypt/live/mydomain/cert.pem'
to:
SSL_cert_file => '/etc/letsencrypt/live/mydomain/fullchain.pem'
Undefined answered
2021-11-26
Link to answer
141
votes
Answer
Solution:
I intended to comment on Yuvik's answer but I lack enough reputation points.
When you import a .crt file to/usr/share/local/ca-certificates, it needs to be in the correct format. Some of these have been mentioned earlier, but no one has mentioned the need for only a new line character, and no one has collected a checklist, so I thought I would provide one while I'm at it.
The certificate needs to end in.crt. From Ubuntu's man page:
Certificates must have a .crt extension in order to be included by update-ca-certificates
Certificate files in/usr/local/share/ca-certificates can only contain one certificate
Certificate files must end in a newline.update-ca-certificates will appear to work if each row contains, for example, a carriage return + a newline (as is standard in Windows), but once the certificate is appended to/etc/ssl/ca-certificates.crt, it still will not work. This specific requirement bit me as we're loading certificates from an external source.
Undefined answered
2021-11-26
Link to answer
117
votes
Answer
Solution:
Had that problem and it was not solved with newer version. /etc/certs had the root cert, the browser said everything is fine. After some testing I got from ssllabs.com the warning, that my chain was not complete (Indeed it was the chain for the old certificate and not the new one). After correcting the cert chain everything was fine, even with curl.
Undefined answered
2021-11-26
Link to answer
551
votes
Answer
Solution:
This is ssh certificate store issue. You need to download the valid certificate pem file from target CA website, and then build the soft link file to instruct ssl the trusted certifacate.
openssl x509 -hash -noout -in DigiCert_Global_Root_G3.pem
you will getdd8e9d41
build solf link with hash number and suffix the file with a .0 (dot-zero)
dd8e9d41.0
Then try again.
Undefined answered
2021-11-26
Link to answer
814
votes
Answer
Solution:
Some systems may have this problem due to conda environment. If you have conda installed then disabling it may solve your problem. In my case when I deactivated conda this curl-SSL error was resolved. On ubuntu or MacOS try this command
conda deactivateUndefined answered
2021-11-26
Link to answer
928
votes
Answer
Solution:
On Amazon Linux (CentOS / Red Hat etc) I did the following to fix this issue. First copy the cacert.pem downloaded from //curl.haxx.se/ca/cacert.pem and put it in the/etc/pki/ca-trust/source/anchors/ directory. Then run theupdate-ca-trust command.
Here is a one liner taken from //serverfault.com/questions/394815/how-to-update-curl-ca-bundle-on-redhat
curl //curl.se/ca/cacert.pem -o /etc/pki/ca-trust/source/anchors/curl-cacert-updated.pem && update-ca-trust
However since curl was broken I actually used this command to download the cacert.pem file.
wget --no-check-certificate //curl.haxx.se/ca/cacert.pem
Also if you were having trouble with php you may need to restart your web serverservice httpd restart for apache orservice nginx restart for nginx.
Undefined answered
2021-11-26
Link to answer
209
votes
Answer
Solution:
I've been pulling my hair out over this issue for days on a Wordpress installation attempting to communicate with an internal ElasticSearch service via ElasticPress and a self-signed Root CA managed by AWS ACM PCA.
In my particular case, I was receiving a 200 OK response from the default cURL Transport as well as the expected body, but Wordpress was coming back with aWP_Error object as well that ElasticPress was picking up due to this certificate issue but never logging.
When it comes to Wordpress, there are two things worth noting:
- The default cURL Transport for all wp_remote_* calls will look to a CA Bundle located inwp-includes/certificates/ca-bundle.crt. This bundle serves largely the same purpose as what's found under //curl.haxx.se/docs/caextract.html, and will cover most use-cases that don't typically involve more exotic setups.
- Action/Filter order matters in Wordpress, and in ElasticPress' case, many of its own internal functions leverage these remote calls. The problem is, these remote calls were being executed during theplugins_loaded lifecycle, which is too early for Theme logic to be able to override. If you're using any plugins that make external calls out to other services and you need to be able to modify the requests, you should take careful note as to WHEN these plugins are performing these requests.
What this means is that even with the right server setup, hooks, callbacks, and logic defined in your theme, you can still end up with a broken setup because the underlying plugin calls execute well before your theme loads and will never be able to tell Wordpress about the new certificates.
In the context of Wordpress applications, there are only two ways I know of that can circumvent this problem without updating core or third-party code logic:
- (Recommended) Add a "Must Use" Plugin to your installation that adjusts the settings you need. MU Plugins load the earliest in the Wordpress lifecycle and will be able to give you the ability to override your plugins and your core without directly altering them. In my case, I set up a simple MU Plugin with the following logic:
- (Not Recommended) If you have absolutely no other options, you can also append your Root CA towp-includes/certificates/ca-bundle.crt. This will seemingly "correct" the underlying issue and you will get proper verification of your SSL Certificates, but this method will fail each time you update Wordpress unless you bake in additional automation.
I'm adding this answer because I had thought that I was doing something wrong or wonky in my setup for days before I ever even bothered to delve deeper into the plugin source code. Hopefully this might save somebody some time if they're doing anything similar.
Undefined answered
2021-11-26
Link to answer
198
votes
Answer
Solution:
So far, I've seen this issue happen within corporate networks because of two reasons, one or both of which may be happening in your case:
- Because of the way network proxies work, they have their own SSL certificates, thereby altering the certificates that curl sees. Many or most enterprise networks force you to use these proxies.
- Some antivirus programs running on client PCs also act similarly to an HTTPS proxy, so that they can scan your network traffic. Your antivirus program may have an option to disable this function (assuming your administrators will allow it).
As a side note, No. 2 above may make you feel uneasy about your supposedly secure TLS traffic being scanned. That's the corporate world for you.
Undefined answered
2021-11-26
Link to answer
368
votes
Answer
Solution:
I had this problem with Digicert of all CAs. I created a digicertca.pem file that was just both intermediate and root pasted together into one file.
curl //cacerts.digicert.com/DigiCertGlobalRootCA.crt.pem curl //cacerts.digicert.com/DigiCertSHA2SecureServerCA.crt.pem curl -v //mydigisite.com/sign_on --cacert DigiCertCA.pem ... * subjectAltName: host "mydigisite.com" matched cert's "mydigisite.com" * issuer: C=US; O=DigiCert Inc; CN=DigiCert SHA2 Secure Server CA * SSL certificate verify ok. > GET /users/sign_in HTTP/1.1 > Host: mydigisite.com > User-Agent: curl/7.65.1 > Accept: */* ...Eorekan had the answer but only got myself and one other to up vote his answer.
Undefined answered
2021-11-26
Link to answer
224
votes
Answer
Solution:
Mine worked by just adding -k to my curl. No need to complicate things.
curl -LOk //dl.k8s.io/release/v1.20.0/bin/linux/amd64/kubectl
Undefined answered
2021-11-26
Link to answer
851
votes
Answer
Solution:
Specifically for Windows users, usingcurl-7.57.0-win64-mingw or similar version.
This is a bit late, and the existing answers are correct. But I still had to struggle a bit to get it working on my Windows machine, though the process is actually pretty straight forward. So, sharing the step-by-step process.
This error basically means, curl is failing to verify the certificate of the target URI. If you trust the issuer of the certificate (CA), you can add that to the list of trusted certificates.
For that, browse the URI (e.g. on Chrome) and follow the steps
- Right click on the secure padlock icon
- Click on certificate, it'll open a window with the certificate details
- Go to 'Certification Path' tab
- Click the ROOT certificate
- Click View Certificate, it'll open another certificate window
- Go to Details tab
- Click Copy to File, it'll open the export wizard
- Click Next
- Select 'Base-64 encoded X.509 (.CER)'
- Click Next
- Give a friendly name e.g. 'MyDomainX.cer' (browse to desired directory)
- Click Next
- Click Finish, it'll save the certificate file
- Now open this.cer file and copy the contents (including -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----)
- Now go to the directory wherecurl.exe is saved e.g.C:\SomeFolder\curl-7.57.0-win64-mingw\bin
- Open thecurl-ca-bundle.crt file with a text editor
- Append the copied certificate text to the end of the file. Save
Now your command should execute fine in curl.
Undefined answered
2021-11-26
Link to answer
People are also looking for
solutions to the problem: fastcgi sent in stderr: "primary script unknown" while reading response header from upstream
Source
Share
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
About the technologies asked in this question
PHP
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own
license.
//www.php.net/
Node.js
Node.js is an open source server-side framework built on top of the Google Chrome JavaScript Engine. The number of sites using NodeJS has increased by 84,000. It is one of the busiest cross-platform JavaScript runtimes. Node.js is an asynchronous, single-threaded, non-blocking I / O model that makes it lightweight and efficient. The Node.js package ecosystem, npm, is also
the world's largest open source library ecosystem.
//nodejs.org/
HTML
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the
way, the code of any page is available to everyone.
//www.w3.org/html/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.