创建自签名证书,在Chrome开启不安全的本地主机之后: 铬://标志/#允许不安全,本地主机HTTPS服务器自签名证书
并添加自签名证书系统后'相信所有'。下面的代码仍然不通过https托管服务器。 显示在镀铬以下错误:
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/...' – robertklep
是的,我冲浪到https:// localhost:8001/ – Vincent
您的证书是CN'localhost'吗?即'CN = localhost' – wablab