信任 Chrome & 中 MEAN 堆栈的 https://localhost:3000/苹果电脑 [英] Trust https://localhost:3000/ of MEAN stack in Chrome & Mac
问题描述
我在 macOS Sierra 10.12.3 中使用 Chrome.我想我很久以前已经为 localhost
设置了 ssl
.现在,Chrome 中的 http://localhost/
和 https://localhost/
都会返回 localhost
下的文件夹列表.我创建了一个 nodejs 应用程序.因此,在命令行中输入 npm start
以运行服务器后,我们可以在 Chrome 中打开 http://localhost:3000/#/home
作为前端.
现在,出于某种原因,我需要让 https://localhost:3000/#/home
在 Chrome 中工作.目前,它给出了 无法访问此站点;localhost 意外关闭连接
错误.
有人知道如何修改吗?我应该在 mac 中还是在我的应用程序代码中设置一些东西?
编辑 1: 我找到了这个页面:
如上面的截图所示,我能够查看它的证书(虽然有一个错误 ERR_CERT_COMMON_NAME_INVALID
).我将证书复制到桌面并将其拖到Keychain Access
工具的login
,并将其设置修改为Always Trust
.我重新启动了 Chrome,重新加载了页面,但 Not Secure
警告仍然存在.
有人可以帮忙吗?
这个问题其实有很多帖子,比较混乱.我写适合我的方式.
我终于按照这个页面生成了文件
I use Chrome in macOS Sierra 10.12.3. I guess I have already set up
ssl
forlocalhost
long time ago. Now, bothhttp://localhost/
andhttps://localhost/
in Chrome return the list of folders underlocalhost
. I have created a nodejs app. So after typingnpm start
in a command line to run the server, we could openhttp://localhost:3000/#/home
as frond-end in Chrome.Now, for some reason, I need to make
https://localhost:3000/#/home
work in Chrome. At the moment, it givesThis site can't be reached; localhost unexpectedly closed the connection
error.Does anyone know how to amend this? Should I set up something in mac or in the code of my app?
Edit 1: I have found this page: SSL/HTTPS server with Node.js and Express.js. So I generated the files and modified the node code. Now loading
https://localhost:3000/#/posts/editor/
displays the page, but I want to remove the annoyingNot Secure
warning.As the above screenshot shows, I was able to view its certificate (though there is an error
ERR_CERT_COMMON_NAME_INVALID
). I copied the certificate to the desktop and dragged it tologin
of theKeychain Access
tool and modified its setting toAlways Trust
. I restarted Chrome, reloaded the page, but theNot Secure
warning is still there.Could anyone help?
解决方案There are actually lots of threads about this issue, which are quite confusing. I write the way that works for me.
I have finally followed this page to generate the files http://blog.mgechev.com/2014/02/19/create-https-tls-ssl-application-with-express-nodejs/. Note that I set
localhost
asCommon Name
(not sure if it's really mandatory).In
www
of my MEAN projectvar fs = require("fs"); var config = { key: fs.readFileSync('key.pem'), cert: fs.readFileSync('cert.pem') }; var server = https.createServer(config, app).listen(3000);
In Chrome, I open
https://localhost:3000/#/new
, then I go to theSecurity
tab ofDev Tools
to view its certificate. Then drag the certificate to the desktop.Double-click the certificate on the desktop, which opens
Keychain Access
. Make sure the certificate is inlogin
(not necessarilysystem
). If it's not, then drag the certificate inlogin
.Change everything to
Always Trust
(maybe restart
Chrome
), afternpm start
the application, enjoy surfinghttps://localhost/#/new
with Green Secure Light.
这篇关于信任 Chrome & 中 MEAN 堆栈的 https://localhost:3000/苹果电脑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!