如何在网站之间共享自签名 TLS 证书

How to share Self-signed TLS certificate between websites

我在同一域示例中有两个网站 app1.test.localapp2.test.lcaol。下面是我用来生成 self-signed 证书的过程。

openssl genrsa -out tls.key 2048
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req

[req_distinguished_name]
countryName = IN
countryName_default = IN
stateOrProvinceName = KA
stateOrProvinceName_default = KA
localityName = Test
localityName_default = Test
organizationalUnitName = test
organizationalUnitName_default = test
commonName = *.test.local
commonName_max = 64
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = *.test.local
openssl req -new -out tls.csr -key tls.key -config openssl.cnf
openssl x509 -req -days 3650 -in tls.csr -signkey tls.key -out tls.crt -extensions v3_req -extfile openssl.cnf

从浏览器的 view certificate 选项中我可以看到 SANCN 都具有 *.test.local 作为值。但是,当我从 app1 启动应用程序 app2 时,浏览器再次提示信任证书 [The certificate is not trusted because it is self-signed.].

问题:如何防止浏览器多次提示Accept the risk and Continue同一证书但来自不同网站的自签名证书。

How to prevent browser from prompting to Accept the risk and Continue multiple times for the same certificate but from different websites for self-signed certificates.

覆盖证书的警告只会影响当前使用的域,而不是证书中的每个域。否则,有人可以为一些无辜的站点创建证书,但其中还包括重要站点的 SAN,例如 paypal.com - 然后重用该证书来冒充重要站点。

要使证书中给定的所有域都信任证书,需要将证书作为受信任的证书显式导入浏览器信任库,而不是简单地忽略证书警告。