Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 自签名SSL证书无效-“;主题替代名称缺失“1”;_Google Chrome_Ssl_Https_Pkix - Fatal编程技术网

Google chrome 自签名SSL证书无效-“;主题替代名称缺失“1”;

Google chrome 自签名SSL证书无效-“;主题替代名称缺失“1”;,google-chrome,ssl,https,pkix,Google Chrome,Ssl,Https,Pkix,最近,Chrome停止使用我的自签名SSL证书,认为它们不安全。当我查看DevTools | Security选项卡中的证书时,我可以看到它显示 主题替代名称缺少此站点的证书 不包含包含域的主题替代名称扩展名 名称或IP地址 证书错误站点的证书链存在问题 (网络::错误证书公共名称无效) 如何修复此问题?要修复此问题,基本上,在创建证书时,您需要向openssl提供一个额外的参数 -sha256-extfile v3.ext 其中,v3.ext是一个类似这样的文件,%%DOMAIN%%替换为与通

最近,Chrome停止使用我的自签名SSL证书,认为它们不安全。当我查看
DevTools | Security
选项卡中的证书时,我可以看到它显示

主题替代名称缺少此站点的证书 不包含包含域的主题替代名称扩展名 名称或IP地址

证书错误站点的证书链存在问题 (网络::错误证书公共名称无效)


如何修复此问题?

要修复此问题,基本上,在创建证书时,您需要向
openssl
提供一个额外的参数

-sha256-extfile v3.ext

其中,
v3.ext
是一个类似这样的文件,
%%DOMAIN%%
替换为与
通用名相同的名称。更多信息和信息。请注意,通常您会将
公共名称
%%DOMAIN%%
设置为您试图为其生成证书的域。因此,如果它是
www.mysupersite.com
,那么您可以将其用于这两者

v3.ext 注意:解决此问题的脚本,以及 另一个注意事项:如果您试图阻止chrome在查看自签名证书时抛出错误,您可以告诉chrome忽略所有站点的所有SSL错误,方法是使用一个特殊的命令行选项启动它,

我能够摆脱(net::ERR\u CERT\u AUTHORITY\u INVALID)通过更改v3.ext文件的DNS.1值

[备选名称] DNS.1=domainname.com


使用您自己的域更改domainname.com。

我只需使用
-subj
参数添加机器ip地址。因此,只需一个命令即可解决

sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -sha256 -subj '/CN=my-domain.com/subjectAltName=DNS.1=192.168.0.222/' -keyout my-domain.key -out my-domain.crt
您可以添加其他属性,如C、ST、L、O、OU、emailAddress,无需提示即可生成证书。

问题 正如其他人所提到的,由于生成的证书不包括SAN(
subjectAltName
)字段,因此出现了
NET::ERR\u CERT\u COMMON\u NAME\u INVALID
错误

自2000年5月以来,已不赞成返回到
commonName
字段。Chrome从58版开始就强制使用了
subjectAltName
字段(请参阅)

OpenSSL接受向证书添加扩展配置(请参阅配置选项字段)


Bash脚本 我创建了一个具有简单选项的应用程序,可以轻松生成证书颁发机构并使用OpenSSL签署x509证书(在Chrome中使用
subjectAltName
字段有效)

脚本将引导您完成一系列问题,包括必要的信息(包括
subjectAltName
字段)。有关自动化的更多详细信息和选项,您可以参考

请确保在安装新证书后重新启动chrome


其他资源
  • Docker文档具有用于创建自签名证书颁发机构和使用OpenSSL对证书进行签名的功能
  • 也是一个非常健壮的工具,被广泛使用,值得一试

以下解决方案在chrome 65上对我有效()-

创建OpenSSL配置文件(示例:req.cnf)

创建引用此配置文件的证书

openssl req -x509 -nodes -days 730 -newkey rsa:2048 \
 -keyout cert.key -out cert.pem -config req.cnf -sha256
MAC上 从chrome版本67.0.3396.99开始,我的自签名证书停止工作

所有写在这里的东西都无法再生

更新

今天有机会确认我的方法有效:)。如果它对你不起作用,请确保你正在使用这种方法

v3.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = <specify-the-same-common-name-that-you-used-while-generating-csr-in-the-last-step>
$
v3.ext
authorityKeyIdentifier=密钥ID,颁发者
基本约束=CA:错误
keyUsage=数字签名、不可否认性、密钥加密、数据加密
subjectAltName=@alt\u名称
[备选名称]
DNS.1=
$
从这里抄来的

结束更新

最后,只有当系统中删除我的证书,并将其添加到本地密钥链时,才能看到绿色安全。(如果有一个-先放下它)。不确定它是否重要,但在我的例子中,我通过chrome下载了证书,并验证了创建日期是今天——所以它就是我刚刚创建的那个

希望这将有助于有人花一天的时间在它上面

永远不要更新chrome

  • 在主目录中复制OpenSSL配置:

    cp /System/Library/OpenSSL/openssl.cnf ~/openssl-temp.cnf
    
    或在Linux上:

    cp /etc/ssl/openssl.cnf ~/openssl-temp.cnf
    
  • [v3\u ca]
    下的
    openssl temp.cnf
    中添加主题替代名称:

    [ v3_ca ]
    subjectAltName = DNS:localhost
    
    用要为其生成证书的域替换
    localhost

  • 生成证书:

    sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
        -config ~/openssl-temp.cnf
        -keyout /path/to/your.key -out /path/to/your.crt
    
    openssl genrsa -out key1.pem
    openssl req -new -key key1.pem -out csr1.pem -config ssl.conf
    openssl x509 -req -days 9999 -in csr1.pem -signkey key1.pem -out cert1.pem -extensions req_ext -extfile ssl.conf
    rm csr1.pem
    

然后,您可以删除openssl temp.cnf

以下是创建Chrome信任的IP证书的一种非常简单的方法

ssl.conf文件

[ req ]
default_bits       = 4096
distinguished_name = req_distinguished_name
req_extensions     = req_ext
prompt             = no

[ req_distinguished_name ]
commonName                  = 192.168.1.10

[ req_ext ]
subjectAltName = IP:192.168.1.10
其中,192.168.1.10当然是我们希望Chrome信任的本地网络IP

创建证书:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -config ~/openssl-temp.cnf
    -keyout /path/to/your.key -out /path/to/your.crt
openssl genrsa -out key1.pem
openssl req -new -key key1.pem -out csr1.pem -config ssl.conf
openssl x509 -req -days 9999 -in csr1.pem -signkey key1.pem -out cert1.pem -extensions req_ext -extfile ssl.conf
rm csr1.pem
在Windows上,将证书导入所有客户端计算机上的受信任根证书存储。在Android手机或平板电脑上下载证书以安装它。现在Chrome将信任windows和Android上的证书


在windows dev box上,获取openssl.exe的最佳位置是“c:\Program Files\Git\usr\bin\openssl.exe”

我在macos/Chrome上获取自签名证书时遇到了很多问题。最后,我找到了Mkcert,“一个简单的零配置工具,可以使用您想要的任何名称生成本地受信任的开发证书。”

如果您想运行服务器localhost,您需要设置
CN=localhost
DNS.1=localhost

[req]
default_bits = 2048
default_md = sha256
distinguished_name = req_distinguished_name
prompt = no
prompt = no
x509_extensions = v3_req

[req_distinguished_name]
C = BR
CN = localhost
emailAddress=contact@example.com
L = Sao Paulo
O = example.com
OU = example.com
ST = Sao Paulo

[v3_req]
authorityKeyIdentifier = keyid, issuer
basicConstraints = CA:FALSE
extendedKeyUsage = serverAuth
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = localhost

更新于2021年6月-Windows 10-Chrome v91答案是

不确定您正在使用哪个版本的XAMPP,但是如果您在该文件中查找包含“openssl x509”的行,您应该能够将上述内容添加到该文件中该行的末尾。对于e
[req]
default_bits = 2048
default_md = sha256
distinguished_name = req_distinguished_name
prompt = no
prompt = no
x509_extensions = v3_req

[req_distinguished_name]
C = BR
CN = localhost
emailAddress=contact@example.com
L = Sao Paulo
O = example.com
OU = example.com
ST = Sao Paulo

[v3_req]
authorityKeyIdentifier = keyid, issuer
basicConstraints = CA:FALSE
extendedKeyUsage = serverAuth
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = localhost