[英]Generate a secure & valid self signed certificate for localhost in all the browsers in Mac and Windows virtual machine
I wanted to generate a valid certificate for localhost in Mac and 192.168.1.1 in Windows virtual machine.我想为 Mac 中的 localhost 和 Windows 虚拟机中的 192.168.1.1 生成有效证书。 I followed this thread in Mac:
我在 Mac 中关注了这个线程:
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = US
ST = VA
L = SomeCity
O = MyCompany
OU = MyDivision
CN = localhost
[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = DNS:localhost,IP:192.168.1.1,IP:127.0.0.1
And the command:和命令:
openssl req -newkey rsa:2048 -x509 -nodes -keyout key.pem -new -out cert.pem -config req.cnf -sha256 -days 3650
Then, I exported the certificate from Chrome and trusted it in Keychain Access in Mac and certmgr
in Windows. It worked well.然后,我从 Chrome 导出了证书,并在 Mac 的 Keychain Access 和 Windows 的
certmgr
中信任它。它运行良好。 And I believe that the certificate was also secure without red warning.而且我相信该证书在没有红色警告的情况下也是安全的。
However, today, I realize that, it shows a "Not Secure" red warning in Chrome, then I tried in different browsers, in Mac and Windows virtual machine.然而,今天,我意识到,它在 Chrome 中显示“不安全”红色警告,然后我在不同的浏览器、Mac 和 Windows 虚拟机中尝试。 It returns different results as below.
它返回如下不同的结果。
Does anyone know how to generate a secure & valid self signed certificate for localhost in all the browsers in Mac and Windows virtual machine?有谁知道如何在 Mac 和 Windows 虚拟机的所有浏览器中为本地主机生成安全有效的自签名证书?
Not Secure with Chrome Version 109.0.5414.119 (Official Build) (x86_64) in Mac: Mac 中的 Chrome 版本109.0.5414.119 (官方构建)(x86_64) 不安全:
Not Secure with Firefox Version 109.0.1518.70 (Official build) (64-bit) in Windows virtual machine: Windows虚拟机中的 Firefox 版本 109.0.1518.70(官方构建)(64 位)不安全:
Not Secure with Firefox 109.0 (64-bit) in Mac在 Mac 中使用Firefox 109.0(64 位)不安全
Secure with Edge Version 109.0.1518.70 (Official build) (64-bit) in Windows virtual machine:在Windows虚拟机中使用 Edge 版本 109.0.1518.70(官方构建)(64 位)进行保护:
Secure with Chrome Version 109.0.5414.120 (Official Build) (64-bit) in Windows virtual machine:在Windows虚拟机中使用 Chrome 版本 109.0.5414.120(官方构建)(64 位)进行保护:
I realize that it is because my frontend calls a backend https://localhost:3000
whose certificate is not valid.我意识到这是因为我的前端调用后端
https://localhost:3000
其证书无效。
I then use the same certificate in https://localhost:3000
as in https://localhost:8000
.然后,我在
https://localhost:3000
中使用与在https://localhost:8000
中相同的证书。 There is no Not Secure
red flag anymore.不再有
Not Secure
的危险信号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.