【问题标题】:Insomnia : Error: SSL peer certificate or SSH remote key was not OK失眠:错误:SSL 对等证书或 SSH 远程密钥不正确
【发布时间】:2022-07-19 15:20:42
【问题描述】:

出于测试目的,我将自己的证书添加到 node.js express 服务器。然后我尝试联系 Insomnia 的帖子,但收到一条错误消息。

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

服务器代码:

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

【问题讨论】:

    标签: node.js express ssl insomnia


    【解决方案1】:

    进入您的设置/首选项并在请求/响应下取消选中验证证书

    【讨论】:

    • 不验证证书会消除使用 HTTPS 的所有好处,此时您不妨使用纯 HTTP。
    【解决方案2】:

    谢谢你的帮助....互联网上有很多其他方法,但你的方法是最好的

    【讨论】:

      猜你喜欢
      • 2012-12-20
      • 2014-05-31
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      • 2011-10-19
      • 1970-01-01
      • 2013-08-02
      • 2011-08-17
      相关资源
      最近更新 更多