问题描述
ArcGIS Enterprise环境下往往需要创建自签名证书。小编之前提供的利用OpenSSL创建自签名证书的方法在chrome上再次遇到了证书无效的错误:
原因概述
Chrome浏览器要求证书中必须包含“Subject Alternative Names”这一参数。
解决方案
修改待用的openssl配置文件
1 拷贝openssl配置文件以备修改
cp /etc/pki/tls/openssl.cnf /home/tomcat8/ssl/
2 修改这一openssl.cnf文件
(1) 找到[ req ] 段落,添加如下配置:
req_extetions = v3_req
(2) 添加v3_req配置信息
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
(3) 添加alt_names配置信息
[ alt_names ]
DNS.1 = linux111.esrichina.com
注:这里填入的即为Subject Alternative Names的域名名称
创建证书
1 创建crt格式的自签名证书
openssl req -sha256 -newkey rsa:2048 -nodes -keyout agsenterprise.key -x509 -days 3650 -out agsenterprise.crt -config /home/tomcat8/ssl/openssl.cnf -extensions v3_req
2 转换为pfx格式的自签名证书
openssl pkcs12 -inkey agsenterprise.key -in agsenterprise.crt -export -out agsenterprise.pfx
对tomcat配置证书(适用于Tomcat 8.5)
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="/home/tomcat8/ssl/agsenterprise.pfx"
certificateKeystoreType="PKCS12" certificateKeystorePassword="xxxxxx" />
</SSLHostConfig>
</Connector>
参考:
https://blog.zencoffee.org/2013/04/creating-and-signing-an-ssl-cert-with-alternative-names/