【发布时间】:2019-03-16 20:39:19
【问题描述】:
我在客户端使用socket io:
const socket = require('socket.io-client')('https://localhost:4200', {secure: true, rejectUnauthorized: false})
在服务器上:
let https = require('https')
let fs = require('fs')
let options = {
key: fs.readFileSync('cert/my.net.key'),
cert: fs.readFileSync('cert/my.net.cert'),
requestCert: false,
rejectUnauthorized: false,
};
const server = https.createServer(options, require('express')())
const io = require('socket.io')(server)
所有服务都正常启动,但在客户端我收到polling-xhr.js:263 GET https://localhost:4200/socket.io/?EIO=3&transport=polling&t=MPa6ZuL net::ERR_CERT_AUTHORITY_INVALID
为什么?怎么了?
【问题讨论】:
-
我有同样的错误,但错误来自我的 Chrome 浏览器。我正在使用带有 nodejs 和 express 的自签名证书。我必须在 Chrome 中单击“继续”才能继续
标签: node.js ssl socket.io certificate self-signed