How to use Insomnia Rest Client with Client Certificates?
Asked Answered
A

3

8

I'm trying to use Insomnia with Client Certificates. I followed this document from the Insomnia documentation. I added my certificate pem files and password.

The problem is that I'm still getting this error:

Error: Couldn't connect to server.

Do you have any idea why? Thanks.

Aerophagia answered 6/6, 2017 at 10:2 Comment(0)
E
10

Insomnia seems rather strict in the rules to apply the client certificate. For example, if you connect to localhost:5050 you should put localhost:5050 as the host. Localhost as such does not work in this case.

Key + Certificate is also the safest way to get working results. I've noticed a number of cases where the encapsulated certificates (PFX) didn't work but the key + certificate file did. I assume that this is related to the way the pfx-certificates are created because it also applies for the browsers I test with.

Engedus answered 20/1, 2018 at 8:29 Comment(2)
I can confirm that I cannot get Insomnia to work correctly with self signed certificates. See this issue and this feature request.Sal
Thanks! After putting a port number into the Host field of the Client Certificate dialog on Mac I'm able to send requests to my server.Kobylak
A
4

I was able to consume an extremely and rare service using insomnia version 2021.4.1. I could not consume it with Soapui nor Postman.

I followed these easy steps. It worked at first attempt :D, just the p12 file was enough on my case.

certificate-client-on-insomnia

Importing Certificates with Insomnia

I will put here the official documentation, in case the link disappears:

Insomnia supports PFX (Mac), and PEM (Windows and Linux) certificates. To import a new certificate, open the Document/Collection Settings dialog – accessible from the top-left menu – and click on the Client Certificates tab. From here, you can add new certificates and view existing ones.

Now lets walk through how to import one.

If you’re familiar with client certificates, the only field needing explanation should be the Host field.

  • Host: certificate will be sent when the host (and port if specified) matches
  • PFX: certificate in PFX or PKCS12 format (Only supported on Mac)
  • CRT File + Key File: certificate and key pair (only supported on Windows and Linux)
  • Passphrase: An optional passphrase for the certificate if required

After importing a certificate, it will show up in the main certificates list. From here, it can be enabled/disabled or deleted.

Anne answered 15/7, 2021 at 15:14 Comment(3)
Will this method of adding certificates in the collection settings of Insomnia, also help to resolve the issue when using SSL certificates (self-signed CA) ?Defection
What is you error?Anne
I have used java keytool command for creating SSL certificate and then using it for establishing HTTPS connection in my springBoot app, with the help of this SO answer - stackoverflow.com/a/62798750. And This SO post - https://mcmap.net/q/544682/-insomnia-error-ssl-peer-certificate-or-ssh-remote-key-was-not-ok/14106566 discusses the same error which I m getting.Defection
Y
0

Insomnia is very strict about self-signed certificates.

I had a similar issue on a Windows environment with Insomnia version 2022.2.1.

My solution was to add the intermediate and root certificates as well to the client certificate (.crt) file with the following order:

-----BEGIN CERTIFICATE-----
client cert
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
intermediate cert
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
root cert
-----END CERTIFICATE-----

Then I imported the client certificate .crt file and .key file for the host and it worked.

Yamada answered 24/3, 2022 at 15:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.