生成的证书需要双击导入系统信任根证书区域
const https = require('https')
const fs = require('fs')
const options = {
// key: fs.readFileSync('./ssl/server.key'),
// cert: fs.readFileSync('./ssl/server.crt')
key: fs.readFileSync('./ssl2/client.key'),
cert: fs.readFileSync('./ssl2/client.crt')
}
const server = https.createServer(options, (req, res) => {
console.log(req.method, req.url)
res.writeHead(200, {'content-type': 'text/plain'})
res.end('foolish someone')
})
const port = 8000
server.listen(port, () => console.log('running at ', port))
网友评论