【发布时间】:2017-02-28 20:51:56
【问题描述】:
创建自签名证书后,在 chrome 中打开不安全的 localhost 后: chrome://flags/#allow-insecure-localhost
在添加自签名证书系统和“全部信任”之后。下面的代码仍然没有通过 https 托管服务器。 chrome中显示如下错误:
This site can’t provide a secure connection localhost sent an invalid response. Try running Network Diagnostics. ERR_SSL_PROTOCOL_ERROR
为此我缺少什么?
var express = require('express');
var https = require('https');
var http = require('http');
var fs = require('fs');
// This line is from the Node.js HTTPS documentation.
var options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
// Create a service (the app object is just a callback).
var app = express();
// Create an HTTP service.
http.createServer(app).listen(8000);
// Create an HTTPS service identical to the HTTP service.
https.createServer(options, app).listen(8001);
【问题讨论】:
-
您是否连接到正确的端口?
https://localhost:8001/... -
是的,我正在浏览 https://localhost:8001/
-
您的证书的 CN 是 'localhost' 吗?即
CN=localhost -
@wablab 试过这个