证书链(自签名根CA)

我正在为内部使用创build一个自签名的根CA,我决定使用中间证书。 但是,我遇到了Chromium和Firefox 54.0不相信证书链的问题。

内容通过Ubuntu 16.04上的Apache 2.4.18进行托pipe,具有以下configuration:

<VirtualHost *:443> DocumentRoot /var/www/html/ SSLCertificateFile /etc/apache2/ssl/server.crt SSLCertificateKeyFile /etc/apache2/ssl/server.key SSLCertificateChainFile /etc/apache2/ssl/fullchain.crt </VirtualHost>

Chromium正在报告“网站证书链存在问题”,以及Firefox“错误代码:SEC_ERROR_CA_CERT_INVALID”。 Chromium和Firefox都将Root CA安装在其信任存储中,作为validation网站的可信证书。

以下是用于生成,签名和validation证书的设置

#Generate and self-sign the Root CA #=========================================================== openssl genrsa -out ca.key 2048 #openssl genrsa -aes256 -out ca.key 4096 openssl req -new -x509 -days 3650 -key ca.key -subj "/C=UK/ST=London/L=/O=SWS, Inc./CN=X1 SWS Root CA" -out ca.crt #===Generate and sign the intermediate CA #============================================================ openssl req -newkey rsa:2048 -nodes -keyout intermediate.key -subj "/C=UK/ST=London/L=/O=SWS Intermediate, Inc./CN=SWS Intermediate CA" -out intermediate.csr openssl x509 -req -extfile <(printf "subjectAltName=DNS:localhost") -in intermediate.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out intermediate.crt -days 2000 -sha256 #===Generate a certificate and sign with the intermediate CA #============================================================ openssl req -newkey rsa:2048 -nodes -keyout server.key -subj "/C=UK/ST=London/L=/O=SWS, Inc./CN=*.sws.com" -out server.csr openssl x509 -req -extfile <(printf "subjectAltName=DNS:sws.com,DNS:*.sws.com") -days 730 -in server.csr -CA intermediate.crt -CAkey intermediate.key -CAcreateserial -out server.crt #===Generate a certificate chain #=========================================================== cat intermediate.crt ca.crt > fullchain.crt #===Verify the certificate (CRT) info #============================================================ openssl x509 -in server.crt -text -noout #===Verifies the Chain of Trust #============================================================ openssl verify -CAfile ca.crt intermediate.crt openssl verify -verbose -CAfile <(cat intermediate.crt ca.crt) server.crt

这看起来相当奇怪,因为证书链是有效的,并且执行相同的步骤而没有中间件在Chromium和Firefox中提供有效的证书链。

请确认域名“sws.com”,是本地DNS; 它是通过hosts文件configuration的。

由于这个话题相当大,我select了下面的URL,详细说明了configuration过程。

使用Jamie Linux上的文档,我创build了一个根和中间CA. 但是,本教程不包含用于替代主题名称的X509v3扩展。 通过修改模块[server_cert]下的intermediate / openssl.cnf文件,添加以下几行即可轻松解决这个问题。

[ server_cert ] ... subjectAltName = @alt_names [ alt_names ] DNS.1 = example.com DNS.2 = www.example.com

已修改的中间configuration文件在下面添加为“configurationICA”。

我最初提出的问题是中间CA没有基本的限制。 因此,它是一个X509v1证书,因此它没有约束来说明它是否是一个CA,并且由于X509v1被弃用,所有浏览器都将自动不信任该信任链。

Jamie Linux: https : //jamielinux.com/docs/openssl-certificate-authority/create-the-root-pair.html
configurationICA: https : //pastebin.com/gCGcFdiP