如何修复Node.js HTTPS服务器"SSL错误"? [英] How to fix Node.js HTTPS Server "SSL Error"?
本文介绍了如何修复Node.js HTTPS服务器"SSL错误"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将express
与node.js https
服务器结合使用,但是在连接时会收到警告.
I'm trying to use express
in conjunction with a node.js https
server, but I'm getting a warning when I connect.
我的代码是:
var WebSocketServer = require('ws').Server
, https = require('https')
, fs = require('fs')
, express = require('express')
, app = express();
app.use(express.static(__dirname + '/public'));
var options = {
rejectUnauthorized: false,
requestCert: true,
agent: false,
key: fs.readFileSync('private/key.pem'),
cert: fs.readFileSync('private/cert.pem')
};
var server = https.createServer(options, app);
server.listen(8888);
var MainServer = new WebSocketServer({server: server});
如何解决此警告(并有效地解决身份未验证问题)?
How do I fix this warning (and effectively the Identity not verified problem)?
谢谢!
推荐答案
这是您的浏览器发出的警告.当您将解决方案付诸实践时,购买证书并与您的域关联(确切地说是通配符或根证书),警告将消失,并且美丽的锁将向世界展示您的网站的安全性. :-)
That's a warning your browser gives. When you take the solution live, buy a certificate and associate with your domain(be exact - wildcard or root certificate) and the warning will go away, and a beatiful lock will come to show the world how safe your site is. :-)
这篇关于如何修复Node.js HTTPS服务器"SSL错误"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文