为了让 Edge 信任本地主机开发服务器,我按照此 tutorial 创建了一个自签名证书。我刚刚用 localhost 替换了 client-1.local 的所有实例。
简而言之,我通过使用命令创建 .pem 文件来创建可信机构
openssl genrsa -des3 -out rootSSL.key 2048
然后
openssl req -x509 -new -nodes -key rootSSL.key -sha256 -days 1024 -out rootSSL.pem
并将它们导入 MMC 中的受信任权限存储中。
然后我创建了一个私钥
openssl req -new -sha256 -nodes -out localhost.csr -newkey rsa:2048 -keyout localhost.key -subj "/C=AU/ST=NSW/L=Sydney/O=Client One/OU=Dev/CN=localhost/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="157078747c795471716770666628797a76747955797a7674793b767a78" rel="noreferrer noopener nofollow">[email protected]</a>"
和证书
openssl x509 -req -in localhost.csr -CA rootSSL.pem -CAkey rootSSL.key -CAcreateserial -out localhost.crt -days 50000 -sha256 -extensions "authorityKeyIdentifier=keyid,issuer\n basicConstraints=CA:FALSE\n keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment\n subjectAltName=DNA:localhost"
双击证书时,该证书将显示为有效。
对于异常(exception)情况,我需要将证书导入浏览器。对于 Firefox,我首先遇到错误
You do not own the private key for the certificate
所以我创建了一个 PKCS12 文件
openssl pkcs12 -export -inkey ./sample.key -in ./sample.crt -out ./sample.p12
并在 Firefox 中的“我的证书”下导入该证书。这有效,我使用 ng 服务“ssl/localhost.crt” 进行托管,并且带有导入的 .p12 的 Firefox 接受我的本地主机。现在,对于 MS Edge,它仍然提示,我的证书无效。
我也尝试过.pfx合并,但没有变化。我还读到证书不应安装在“我的证书”下,而应作为“权威”安装。这对我来说听起来不对,但我尝试了并将 .crt 和 .p12 导入到 Authorities 和 Root Authority,因为为什么不,但没有改变。我还通过 Windows 向导安装了证书。
我对 MS Edge 缺少什么?遗憾的是我没有办法解决这个问题。
=====更新=====
其他信息:
Edge 没有给出任何有用的错误。 Here是消息的图像。它是德语,但它只显示默认文本“连接不安全。证书无效。您的信用卡信息可能被盗。”如果有什么方法可以为 Edge 获取更多信息,我将非常高兴。在开发者控制台中,消息是:
This site does not have a valid SSL certificate! Without SSL, your site's and visitors' data is vulnerable to theft and tampering. Get a valid SSL certificate before releasing your website to the public.
可以查看证书文件和openssl x509 -text localhost.crt
的输出 here (密码是 pass 或密码,如有必要)和 .crt here 的图像。它位于我的开发文件夹中,我使用该网站托管
ng serve --ssl true --ssl-cert \"ssl/localhost.crt\" --ssl-key \"ssl/localhost.key\"
并通过localhost:3000本地访问服务器。
我通过管理证书 -> 我的证书 -> 导入将 .p12 文件导入到 Edge 中。结果看起来像 this .
最佳答案
What am I missing for MS Edge? I
该证书不包含任何使用者备用名称,这使其对 Edge 和 Chrome 无效。尝试指定这些信息,但该尝试是错误的。
I created a selfsigned certificate following this tutorial.
看起来这个教程已经损坏了。
openssl x509 -req ... -extensions "authorityKeyIdentifier ... subjectAltName=DNA:localhost"
-extension
命令行选项用于指定配置文件中扩展部分的名称,而不是扩展本身。此外,subjectAltName
应该是 DNS:...
而不是 DNA:...
。
要修复,请创建一个扩展文件 my.ext
,其中包含您要使用的扩展:
[myext]
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName=DNS:localhost
然后使用 -extfile my.ext
将此文件用作扩展文件,并指定要与 -extensions myext
一起使用的扩展名:
openssl x509 -req ... -extfile my.ext -extensions myext
关于windows - MS Edge (Windows 10) 不接受自签名证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71470513/