MS Edge (Win 10) 不接受 SelfSignedCertificate

SelfSignedCertificate not accepted in MS Edge (Win 10)

为了让 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/emailAddress=local@local.com"

和带有

的证书
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"

证书在双击时显示为有效。

对于例外情况,我需要将证书导入浏览器。对于 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 serve "ssl/localhost.crt" 进行托管,使用导入的 .p12 的 Firefox 接受我的本地主机。现在对于 MS Edge,它仍然抱怨,我的证书无效。

我也试过.pfx-合并,但没有改变。我还阅读了证书不应该安装在我的证书下,而是作为授权机构。这对我来说听起来不对,但我试过了并将 .crt.p12 都导入了 AuthoritiesRoot Authorities,因为为什么没有,但没有变化。我还通过 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 (password is pass or password, if necessary) and an image of the .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