16

I added my own certificate to a node.js express server for testing purposes. Then I attempted to contact the post from Insomnia, but I received an error message.

Error: SSL peer certificate or SSH remote key was not OK

The server code:

const express = require('express');
const path = require('path');
const fs = require("fs");
var https = require('https');

var privateKey = fs.readFileSync('cert/server.key');
var certificate = fs.readFileSync('cert/server.crt');

var credentials = {key: privateKey, cert: certificate};
const app = express()
const port = 8000
// app.use(express.urlencoded()); 
app.use(express.json());
// Routes
app.get('/', (req, res) => {
  res.sendFile(path.join(__dirname, './public/index.html'));
})
 
app.post('/signin', (req, res) => {
  console.log(req.body.username);
  methods.signin();
  res.end();
})

app.use(express.static('public'))
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(port);
console.log('Server started at https://localhost:' + port);

ErmiaHP
  • 175
  • 1
  • 1
  • 7

1 Answers1

36

Go into your setting/preferences and under Request/Response uncheck Validate certificates
Uncheck Validate Certificates

Geeky Quentin
  • 2,469
  • 2
  • 7
  • 28
nick3point5
  • 392
  • 3
  • 2
  • 5
    Not validating certificates removes all benefits of using HTTPS, at which point you might as well use plain HTTP. – Patrick Mevzek May 30 '22 at 15:13
  • 5
    For testing purposes you can disable, but Patrick is correct you lose all security benefits. An acceptable answer should include how to fix the issue. – timj98 Sep 15 '22 at 15:41
  • 1
    This appears to be a known bug in Insomnia that, as of June 2023, is still not fixed: https://github.com/Kong/insomnia/issues/2255 – Seth Jun 29 '23 at 18:26