我已经为localhostCN创建了一个自签名的SSL证书。正如预期的那样,Firefox在最初抱怨后接受了这个证书。然而,Chrome和IE拒绝接受它,即使在将证书添加到Trusted Roots下的系统证书存储之后。尽管当我在Chrome的HTTPS弹出窗口中单击“查看证书信息”时,证书被列为正确安装,但它仍然坚称证书不可信。
我该怎么做才能让Chrome接受证书并停止抱怨?
我已经为localhostCN创建了一个自签名的SSL证书。正如预期的那样,Firefox在最初抱怨后接受了这个证书。然而,Chrome和IE拒绝接受它,即使在将证书添加到Trusted Roots下的系统证书存储之后。尽管当我在Chrome的HTTPS弹出窗口中单击“查看证书信息”时,证书被列为正确安装,但它仍然坚称证书不可信。
我该怎么做才能让Chrome接受证书并停止抱怨?
当前回答
要在Windows中创建Chrome v58及更高版本将信任的自签名证书,请使用提升的权限启动Powershell并键入:
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -Subject "fruity.local" -DnsName "fruity.local", "*.fruity.local" -FriendlyName "FruityCert" -NotAfter (Get-Date).AddYears(10)
#notes:
# -subject "*.fruity.local" = Sets the string subject name to the wildcard *.fruity.local
# -DnsName "fruity.local", "*.fruity.local"
# ^ Sets the subject alternative name to fruity.local, *.fruity.local. (Required by Chrome v58 and later)
# -NotAfter (Get-Date).AddYears(10) = make the certificate last 10 years. Note: only works from Windows Server 2016 / Windows 10 onwards!!
完成此操作后,证书将保存到个人\证书存储下的本地计算机证书中。
您要将此证书复制到受信任的根证书颁发机构\证书存储。
一种方法是:单击Windows开始按钮,然后键入certlm.msc。然后按照下面的屏幕截图将新创建的证书拖放到Trusted Root Certification Authority\Certificates存储区。
其他回答
我继续使用bjnord建议的方法,即:Google Chrome、Mac OS X和自签名SSL证书
博客中显示的内容不起作用。
然而,该博客的一条评论是金色的:
sudo安全添加可信证书-d-r trustRoot-k/Library/Keychains/Systemkeychain site.crt
你需要关注博客中关于如何获取cert文件的内容,然后你可以使用上面的命令,应该很好。
更新日期:2020年4月23日
铬团队推荐
https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins#TOC-测试强大功能
快速超级简单解决方案
有一个秘密的绕过短语,可以在错误页面中输入,让Chrome不顾安全错误继续运行:这是不安全的(在早期版本的Chrome中,键入baddidea,甚至更早版本的危险)。除非你完全明白为什么需要它,否则不要使用它!
资料来源:
https://chromium.googlesource.com/chromium/src/+/d8fc089b62cd4f8d907acff6fb3f5ff58f168697%5E%21/
(注意,window.atob('dGhpc2lzdW5zYWZl')解析为此isnsafe)
源的最新版本为@https://chromium.googlesource.com/chromium/src/+/refs/heads/master/components/security_interentials/corebrowser/resources/intertial_large.js和window.atob函数可以在js控制台中执行。
有关Chrome团队为何更改旁路短语(第一次)的背景信息:
https://bugs.chromium.org/p/chromium/issues/detail?id=581189
如果所有其他方法都失败(解决方案1)
对于快速一次性,如果“无论如何继续”选项不可用,或者旁路短语也不起作用,这个黑客很好:
通过启用此标志,允许来自本地主机的证书错误(注意,更改标志值后,Chrome需要重新启动):chrome://flags/#allow-不安全的本地主机(并投票赞成答案https://stackoverflow.com/a/31900210/430128作者@Chris)如果要连接的站点是localhost,那么就完成了。否则,设置TCP隧道以在本地侦听端口8090,并连接到端口443上的broken-remote-site.com,确保已安装socat并在终端窗口中运行以下内容:socat tcp侦听:8090,reuseddr,fork tcp:断开远程站点.com:443去https://localhost:8090在浏览器中。
如果所有其他方法都失败(解决方案#2)
类似于“如果所有其他都失败(解决方案#1)”,这里我们使用ngok为本地服务配置代理。因为您可以通过TLS访问ngrok http隧道(在这种情况下,它由ngrok使用有效证书终止),也可以通过非TLS端点访问,所以浏览器不会抱怨证书无效。
下载并安装ngrok,然后通过ngrok.io公开它:
ngrok http https://localhost
ngok将启动并为您提供一个可以连接到的主机名,所有请求都将通过隧道传输回本地计算机。
我不得不调整macosx上的Chrome启动程序,并添加了以下脚本。保存如下:;
/应用程序/Google\Chrome.app/Contents/MacOS/Chrome.com命令
#!/bin/sh
RealBin="Google Chrome"
AppDir="$(dirname "$0")"
exec "$AppDir/$RealBin" --ignore-certificate-errors "$@"
当我用这个脚本启动Chrome时,自签名证书可以正常工作。但是,不要使用使用此脚本启动的浏览器浏览网页,您将不会收到有关无效证书的警告!
我刚刚在我的chrome中启用了允许不安全的localhost标志,就这样。
步骤。
类型chrome://flags在您的铬标签中。搜索允许不安全的本地主机标志并启用它。重新启动chrome浏览器。
现在,您将不会看到不安全的警告https://localhost地点。
mkdir CA
openssl genrsa -aes256 -out CA/rootCA.key 4096
openssl req -x509 -new -nodes -key CA/rootCA.key -sha256 -days 1024 -out CA/rootCA.crt
openssl req -new -nodes -keyout example.com.key -out domain.csr -days 3650 -subj "/C=US/L=Some/O=Acme, Inc./CN=example.com"
openssl x509 -req -days 3650 -sha256 -in domain.csr -CA CA/rootCA.crt -CAkey CA/rootCA.key -CAcreateserial -out example.com.crt -extensions v3_ca -extfile <(
cat <<-EOF
[ v3_ca ]
subjectAltName = DNS:example.com
EOF
)