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

Issue

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);

Solution

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

Answered By – nick3point5

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published