首页 > 解决方案 > 为什么 NET::ERR_CERT_COMMON_NAME_INVALID 在 admin.localhost 上出现 chrome 错误,SAN 和 CN 设置为 *.localhost

问题描述

我想创建一个 http/2 服务器,并将管理面板附加为子域。

我使用 CN=*.localhost 和 subjectAltName = *.localhost 和 localhost 创建了证书

# server.scr.cnf
[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn

[dn]
CN = *.localhost
OU=Random
C=US
ST=RandomState
L=RandomCity
O=RandomOrganization
emailAddress=hello@example.com

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

[alt_names]
DNS.1 = *.localhost
DNS.2 = localhost

然后我去了 chrome(在 stable (88.0.4324.146) 和 canary (90.0.4410.2) 版本上测试,没有差异)并看到了这些结果:

  1. https://localhost:7000 工作正常,没有错误。
  2. https://admin.localhost:7000不起作用,但我例外的是证书不会给出任何错误(服务器端没有错误,继续 admin.localhost:7000 会给出适当的页面) - 证书和错误

我尝试将 CN 更改为 localhost,尝试添加更多通配符,例如 *.*.localhost (等等),但这些都不起作用。
解决我看到的问题的唯一方法是将 admin.localhost 添加到 alt_names,但这对我来说是一个负担,因为需要将每个子添加到 alt_names,所以我不喜欢这个解决方案,我想了解为什么没有't *.localhost 工作。

标签: certificate

解决方案


推荐阅读