为了让 Edge 信任本地主机开发服务器,我创建了一个自签名证书tutorial https://zeropointdevelopment.com/how-to-get-https-working-in-windows-10-localhost-dev-environment/。我刚刚用 localhost 替换了 client-1.local 的所有实例。
简而言之,我通过使用以下命令创建 .pem 文件来创建受信任的权限
openssl genrsa -des3 -out rootSSL.key 2048
and then
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/[email protected] /cdn-cgi/l/email-protection"
和证书
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 服务“ssl/localhost.crt”和 Firefox 导入.p12接受我的本地主机。现在,对于 MS Edge,它仍然抱怨,我的证书无效。
我也尝试过.pfx- 合并,但没有变化。我还读到证书不应安装在“我的证书”下,而应作为“权威”安装。这对我来说听起来不对,但我尝试了并导入了.crt和.p12 into 当局 and 根权限,因为为什么不,但没有改变。我还通过 Windows 向导安装了证书。
我对 MS Edge 缺少什么?遗憾的是我没有办法解决这个问题。
=====更新=====
附加信息:
Edge 不会给出任何有用的错误。Here https://api.leeway.tech/edge%20error___m6n84jd9.PNG是消息的图像。它是德语的,但它只显示默认文本“连接不安全。证书无效。您的信用卡信息可能被盗。”如果有什么方法可以为 Edge 获取更多信息,我将非常高兴。在开发者控制台中,消息是:
该网站没有有效的 SSL 证书!如果没有 SSL,您的网站和访问者的数据很容易被盗窃和篡改。在向公众发布您的网站之前,先获取有效的 SSL 证书。
证书文件和输出openssl x509 -text localhost.crt
可以查看here https://filetransfer.io/data-package/SUKk1mxP#link(密码是 pass 或密码,如有必要)和 .crt 的图像here https://api.leeway.tech/ccert___1aprgqru.PNG。它位于我的开发文件夹中,我用它托管该网站
ng serve --ssl true --ssl-cert \"ssl/localhost.crt\" --ssl-key \"ssl/localhost.key\"
并通过 localhost:3000 本地访问服务器。
我通过管理证书 -> 我的证书 -> 导入将 .p12 文件导入到 Edge 中。结果看起来像this https://api.leeway.tech/edge%20import___1qnokgve.PNG.