您的连接不是私有NET :: ERR_CERT_AUTHORITY_INVALID Node.js本地主机

时间:2019-04-27 17:41:44

标签: node.js ssl

我正在尝试在本地主机上测试ssl,并在Chrome中收到错误Your connection is not private。我确实将自己的/etc/hosts更改为添加127.0.0.1 example.com并转到https://example.com:5001,但仍然收到错误消息

这是我的代码:

const https = require('https')
const express = require('express')
const selfsigned = require('selfsigned')

const app = express()
app.get('/', (req, res) => res.send('hello'))

const attrs = [{name: 'commonName', value: 'example.com'}]
const pems = selfsigned.generate(attrs, {days: 365})
https.createServer({key: pems.private, cert: pems.cert}, app).listen(5001)

0 个答案:

没有答案