我在 macOS Sierra 10.12.3 中使用 Chrome。我想我已经设置好了ssl
for localhost
很久以前。现在,两者http://localhost/
and https://localhost/
在 Chrome 中返回下面的文件夹列表localhost
。我创建了一个nodejs应用程序。所以输入后npm start
在命令行中运行服务器,我们可以打开http://localhost:3000/#/home
作为 Chrome 中的前端。
现在,出于某种原因,我需要做https://localhost:3000/#/home
在 Chrome 中工作。目前,它给出了This site can't be reached; localhost unexpectedly closed the connection
error.
有谁知道如何修改这个?我应该在 mac 中还是在我的应用程序代码中设置一些东西?
Edit 1:我找到了这个页面:使用 Node.js 和 Express.js 的 SSL/HTTPS 服务器 http://kyrcha.info/2014/10/14/sslhttps-server-nodejs-expressjs/。所以我生成了文件并修改了节点代码。正在加载https://localhost:3000/#/posts/editor/
显示页面,但我想删除烦人的Not Secure
警告。
如上面的屏幕截图所示,我能够查看其证书(尽管有错误ERR_CERT_COMMON_NAME_INVALID
)。我将证书复制到桌面并拖到login
of the Keychain Access
工具并将其设置修改为Always Trust
。我重新启动 Chrome,重新加载页面,但是Not Secure
警告仍然存在。
有人可以帮忙吗?
关于这个问题其实有很多帖子,而且很混乱。我以适合我的方式写作。
我终于按照这个页面生成了文件http://blog.mgechev.com/2014/02/19/create-https-tls-ssl-application-with-express-nodejs/ http://blog.mgechev.com/2014/02/19/create-https-tls-ssl-application-with-express-nodejs/。注意我设置的localhost
as Common Name
(不确定这是否真的是强制性的)。
-
In www
我的 MEAN 项目
var fs = require("fs");
var config = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
var server = https.createServer(config, app).listen(3000);
在 Chrome 中,我打开https://localhost:3000/#/new
,然后我去Security
tab of Dev Tools
查看其证书。然后将证书拖到桌面上。
双击桌面上的证书,打开Keychain Access
。确保证书位于login
(不必要system
)。如果不是,则将证书拖入login
.
将所有内容更改为Always Trust
(也许重新启动Chrome
), 后npm start
应用程序,享受冲浪https://localhost/#/new
与绿色安全灯。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)