Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insomnia and NodeJS: "Error: Peer certificate cannot be authenticated with given CA certificates"

Tags:

node.js

curl

ssl

I'm trying to send a GET request using the Insomnia app to a NodeJS server app -- I didn't write the app but have joined the team.

Although I get a reasonable JSON response when I hit the URL -- https://127.0.0.1:9999 -- from the browser, I get the error "Error: Peer certificate cannot be authenticated with given CA certificates" when I'm using Insomnia. Using a Mac, MacOS 10.12.4. Node v6.3.1.

The Insomnia timeline says:

* Preparing request to https://127.0.0.1:9999/
* Enable automatic URL encoding
* Enable SSL validation
* Enable cookie sending with jar of 2 cookies
* Hostname in DNS cache was stale, zapped
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 9999 (#8)
* WARNING: using IP address, SNI is being disabled by the OS.
* SSL certificate problem: Invalid certificate chain
* Curl_http_done: called premature == 1
* Closing connection 8

Thanks for any help!

like image 698
Cerulean Avatar asked Jun 22 '17 16:06

Cerulean


People also ask

How do I fix peer certificate Cannot be authenticated with given CA certificates?

It can be caused by the fact that the certificate is self-signed. To avoid the error, disable the verification from the GitHub side by clicking the Disable SSL verification button for the corresponding webhook.

How do I add certificates to insomnia?

Insomnia supports PFX (Mac) and PEM (Windows and Linux) certificates. To import a new certificate, click Document Settings or Collection Settings then the Client Certificates tab.

What is SSL peer certificate?

Peer authentication means that the other side of the SSL connection is authenticated based on a trusted certificate installed locally. Alternatively, a Certification Authority (CA) certificate may be installed locally and the peer has a certificate signed by that authority.


1 Answers

There is little documentation on how Insomnia handles certificates. As long as they are normal certificates that are signed by a typical CA authority there is typically no problem. Since you also refer to your loopback address (127.0.0.1) I assume that you're also testing with a self-signed certificate.

I noticed that Insomnia uses the Mozilla list of certificate authorities. It does not use the list of your operating system.

The list is stored in a text-file in a directory like C:\Temp\insomnia_5.12.4. In my case it was for example 2017-01-18.pem. You can add your own signing authority certificate to this file.

I didn't look into how stable this file is or how it is created.

You can also workaround the certificate errors by disabling them in your settings (settings > Validate SSL Certificates).

like image 193
fvanrysselberghe Avatar answered Oct 02 '22 02:10

fvanrysselberghe