我已经为localhostCN创建了一个自签名的SSL证书。正如预期的那样,Firefox在最初抱怨后接受了这个证书。然而,Chrome和IE拒绝接受它,即使在将证书添加到Trusted Roots下的系统证书存储之后。尽管当我在Chrome的HTTPS弹出窗口中单击“查看证书信息”时,证书被列为正确安装,但它仍然坚称证书不可信。
我该怎么做才能让Chrome接受证书并停止抱怨?
我已经为localhostCN创建了一个自签名的SSL证书。正如预期的那样,Firefox在最初抱怨后接受了这个证书。然而,Chrome和IE拒绝接受它,即使在将证书添加到Trusted Roots下的系统证书存储之后。尽管当我在Chrome的HTTPS弹出窗口中单击“查看证书信息”时,证书被列为正确安装,但它仍然坚称证书不可信。
我该怎么做才能让Chrome接受证书并停止抱怨?
当前回答
只需要5个openssl命令,就可以完成这一任务。
(请不要更改浏览器安全设置。)
使用以下代码,您可以(1)成为自己的CA,(2)然后将SSL证书签署为CA。(3)然后将CA证书(而不是服务器上的SSL证书)导入Chrome/Chrum。(是的,即使在Linux上也可以。)
注意:对于Windows,一些报告说openssl必须与winpty一起运行以避免崩溃。
######################
# Become a Certificate Authority
######################
# Generate private key
openssl genrsa -des3 -out myCA.key 2048
# Generate root certificate
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 825 -out myCA.pem
######################
# Create CA-signed certs
######################
NAME=mydomain.example # Use your own domain name
# Generate a private key
openssl genrsa -out $NAME.key 2048
# Create a certificate-signing request
openssl req -new -key $NAME.key -out $NAME.csr
# Create a config file for the extensions
>$NAME.ext cat <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = $NAME # Be sure to include the domain name here because Common Name is not so commonly honoured by itself
DNS.2 = bar.$NAME # Optionally, add additional domains (I've added a subdomain here)
IP.1 = 192.168.0.13 # Optionally, add an IP address (if the connection which you have planned requires it)
EOF
# Create the signed certificate
openssl x509 -req -in $NAME.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial \
-out $NAME.crt -days 825 -sha256 -extfile $NAME.ext
概括如下:
成为CA使用CA cert+密钥签署证书在您的Chrome设置(设置>管理证书>权限>导入)中将myCA.pem作为“权限”(而不是“您的证书”)导入使用服务器中的$NAME.crt和$NAME.key文件
额外步骤(至少适用于Mac):
在“文件>导入文件”中导入CA证书,然后在列表中找到它,右键单击它,展开“>信任”,然后选择“始终”在basicConstraints=CA:FALSE下面添加extendedKeyUsage=serverAuth,clientAuth,并确保在请求设置时将“CommonName”设置为与$NAME相同
您可以检查您的工作以确保正确生成证书:
openssl verify -CAfile myCA.pem -verify_hostname bar.mydomain.example mydomain.example.crt
其他回答
对于使用NX的带有Angular Micro前端的mac
步骤1:创建自签名根证书
openssl req -x509 -nodes -new -sha256 -days 390 -newkey rsa:2048 -keyout "RootCA.key" -out "RootCA.pem" -subj "/C=de/CN=localhost.local"
openssl x509 -outform pem -in "RootCA.pem" -out "RootCA.crt"
步骤2:定义应包含在证书中的域和子域
为此,只需创建一个名为vhosts_domains.ext的文本文件并插入以下内容:
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = *.mixable.blog.local
DNS.3 = mixable.blog.local
此示例包括域mixeble.blog.local的本地开发环境的子域以及所有子域,如www.mixable.blog.loal或apps.mixeble.blog.local。
步骤3:创建证书
openssl req -new -nodes -newkey rsa:2048 -keyout localhost.key -out localhost.csr -subj "/C=de/ST=State/L=City/O=Organization/CN=localhost.local"
openssl x509 -req -sha256 -days 1024 -in localhost.csr -CA RootCA.pem -CAkey RootCA.key -CAcreateserial -extfile vhosts_domains.ext -out localhost.crt
步骤4:使证书可用于Angular应用程序
nx serve host --open --devRemotes=<app names> --ssl --ssl-key <folder_location>/localhost.key --ssl-cert <folder_location>/localhost.crt
步骤5:将证书从导入添加到macOS密钥链
在chrome上,如果您仍然获得无效证书,则下载证书并添加到密钥链,并使所有证书都可信。
对于Fedora、Ubuntu、Linux,如果您在使用gui添加证书以添加新的根权限时遇到example.com Not a Certification authority错误。如果您希望信任服务器自签名证书,它不能提及无效的授权。。。即使这是它自己。我只通过信任我的权限并使用该权限密钥对服务器证书进行签名来使其工作。
这是它接受的自签名CA证书。这是我找到绕过cert_authority_invalid的唯一方法,我花了几个小时试图让它接受一个自签名的端点证书,没有雪茄。只要声明为CA:TTRUE,用户界面将接受自签名授权。之后,chrome将接受由具有正确DN的密钥签名的所有证书,而无需单独添加它们。
openssl req-new-x509-extensions v3_req-days 8440-config ca.conf-key rockstor.key-out rockstor.cert
[req]
distinguished_name=dn
req_extensions=v3_req
prompt = no
[v3_req]
basicConstraints=CA:TRUE,pathlen:0
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=@alt_names
[alt_names]
DNS.1 = ca.tdpowerskills.com
[dn]
C = US
ST = LA
L = Alexandria
O = TDPS Certification Authority
OU = LEARNOPS
CN = ca.tdpowerskills.com
openssl req-new-x509-extensions v3_req-days 8440-config config.conf-key rockstor.key-out rockstor.cert
[req]
distinguished_name=dn
req_extensions=v3_req
prompt = no
[v3_req]
basicConstraints=CA:FALSE
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=@alt_names
issuerAltName=DNS:ca.tdpowerskills.com
[alt_names]
DNS.1 = big.tdps.app
[dn]
C = US
ST = LA
L = Alexandria
O = TDPS Certification Authority
OU = LEARNOPS
CN = ca.tdpowerskills.com
如果这不起作用:
chrome://restart实际重新启动尝试使用firefox获取有关错误的更多详细信息,它会更好地解释错误。。。当chrome会说ERR_CERTIFICATE_INVALID时,firefox会抛出:MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY。请记住,chrome现在需要Subject Alternate Name,并且几乎忽略CN。
对于其他人:
certutil-d sql:$HOME/.pki/nssdb-A-t“P,,”-n<昵称>-i<my.crt>//用于服务器支持certutil-d sql:$HOME/.pki/nssdb-A-t“C,,”-n<昵称>-i<my.crt>用于CAhttps://blogs.oracle.com/meena/about-trust-flags-of-certificates-in-nss-database-that-can-be-modified-by-certutil对于Firefox,添加异常证书的UI确实有效,一旦你这样做,它就会信任它。也许您在/etc/pki/tls/openssl.cnf中有一些时髦的设置,这些设置与您的配置合并在一起。也许您没有向配置或命令行添加扩展,例如v3_req注意,我的方法只需使用授权密钥签署证书并添加开发服务器的详细信息,就不需要CSR。CSR允许更多密钥用于实际安全。我尝试了一切,但chrome需要具有基本约束CA:true集的权限。服务器证书必须由有效的授权机构签名。。。即使这只是他们用CA签名的另一个证书:true。
修复Windows上的Chrome。
首先,您需要导出证书。
在浏览器中找到url。url的“https”段将为用红线划掉,左侧将有一个锁定符号。右键单击划掉的“https”段。您将看到一个包含各种信息的信息窗口单击“详细信息”。导出证书,按照说明接受默认设置。
要导入
转到Chrome设置单击“高级设置”在HTTPS/SSL下单击“管理证书”转到“受信任的根证书颁发机构”单击“导入”将出现一个弹出窗口,询问您是否要安装此证书。单击“是”。
在这里,我的WINDOWS解决方案可能适用于LINUX
Git有openssl
C: \Program Files\Git\usr\bin\openssl.exe。
导航到C:\Program Files\Git\user\bin\,但最好添加到PATH
为证书创建文件夹创建文件req.cnf像我的公司一样改变价值观不要删除subjectAltName=@alt_names[备选名称]DNS.1=本地主机Chrome抱怨
C=CA CA是两个字母国家代码CA=加拿大、美国。。。ST=ON是安大略省
请求cnf
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = CA
ST = ON
L = Toronto
O = MyCompany
OU = MyDivision
CN = localhost
[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = www.mydomainname.com
DNS.3 = mydomainname.com
在CMD中创建证书
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt -config req.cnf -sha256
cat server.crt server.key > server.pem
覆盖dev证书
yourproject\node_modules\webpack-dev-server\ssl with the **server.pem**
在chrome设置->管理证书
将server.crt导入到受信任的认证授权重新启动chrome
在package.json中
"scripts": {
"start": "set HTTPS=true&&react-scripts start",
2021 6月-Windows 10-Chrome v91(SIMPLE)
按照selfsignedcertificate.com上的证书生成说明进行操作:
示例域名:mydomain.local,请将其替换为您的域名。
要生成密钥,请执行以下操作:openssl genrsa-out mydomain.local.key 2048创建仅包含以下内容的配置文件mydomain.local.conf:[要求]区分名称=请求[桑]subjectAltName=DNS:mydomain.local注意:在subjectAltName中,您可以定义更多域(可选),如:subjectAltName=DNS:mydomain.local,DNS:*.mydomain.local,DNS:其他域.local,IP:192.168.1.10创建证书:openssl req-new-x509-key mydomain.local.key-out mydomain.local.crt-days 3650-subj/CN=mydomain.local-extensions SAN-config mydomain.local.conf将证书添加到受信任的根证书颁发机构右键单击mydomain.local.crt文件从上下文菜单中选择安装证书。在弹出窗口中选择本地机器。选择“将所有证书放置在以下存储中”。单击浏览。选择受信任的根证书颁发机构。单击“确定”、“下一步”、“完成”。重新启动Chrome。