我正在尝试在本地主机上测试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)