且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法加载资源:net :: ERR_INSECURE_RESPONSE socket.io

更新时间:2022-03-19 23:26:08

在使用官方而非自签名证书时,我遇到了类似的问题,而我刚刚找到了解决方案.它仅在Android chrome上失败,顺便说一句. 将证书链添加到https.createServer方法的options对象:

I had a similar issue when using an offical, not self signed certificate and I just found the solution. It only failed in chrome on Android, btw. Add the certifate chain to the options object of the https.createServer method:

var hskey = fs.readFileSync('/the_key.key');
var hscert = fs.readFileSync('/the_cert.pem')
var ca = fs.readFileSync('/The_CA_bundle.pem')

var credentials = {
    ca:ca,
    key: hskey,
    cert: hscert
};

var server = https.createServer(credentials,app).listen(app.get('port'), function(){
  console.log("Express server listening on port with https " + app.get('port'));
});

只需将其放在此处,以防止其他人在遇到类似问题时将头撞到墙上.

Just putting it here, to prevent someone else banging his head against the wall when having a similar issue.