比较疑惑的是,他的证书使用https的证书吗?
我的代码大概是这样的
var https=require('https');
var ws=require('ws');
var fs=require('fs');
var keypath=process.cwd()+'/ssl_certificate_key.key';
var certpath=process.cwd()+'/ssl_certificate.pem';
var options = {
key: fs.readFileSync(keypath),
cert: fs.readFileSync(certpath)
};
var server=https.createServer(options, function (req, res) {
res.writeHead(403);
res.end("This is a WebSockets server!\n");
}).listen(80);
var wss = new ws.Server( { server: server } );
程序能够运行起来,但是连接报错
error: Error: Hostname/IP doesn't match certificate's altnames: "IP: 127.0.0.1 is not in the cert's list: "
我的证书是某个域名的证书,不是自己生成的,是在阿里云申请的
怎么都是突然就找到答案了
ssl以后,访问必须以域名,不能ip。