如何生成多域名证书

多域名证书

https://www.digicert.com/subject-alternative-name.htm

Multi-Domain (SAN) Certificates - Using Subject Alternative Names 使用者备用名称

The Subject Alternative Name Field Explained

The Subject Alternative Name field lets you specify additional host names (sites, IP addresses, common names, etc.) to be protected by a single SSL Certificate, such as a Multi-Domain (SAN) or Extend Validation Multi-Domain Certificate.

SAN域让你可以指定被单个SSL证书保护的额外的主机名(站点名称、IP地址等等)。

打开一个https网站,如https://www.baidu.com/,点击地址栏上绿色的锁,查看它的证书,点击详细信息,找到“使用者备用名称”,可以看到里面有很多网址。


 

生成多域名证书的步骤

第一步:生成多域名证书的CSR

方法一:用openssl生成多域名证书的CSR

How to generate a new Certificate Signing Request (CSR):

Generate a TLS private key if you don't have one:

openssl genrsa 4096 > domain.key

Generate a CSR for your the domains you want certs for:

(replace "foo.com" with your domain)

Linux:

#change "/etc/ssl/openssl.cnf" as needed:

#  Debian: /etc/ssl/openssl.cnf

#  RHEL and CentOS: /etc/pki/tls/openssl.cnf

#  Mac OSX: /System/Library/OpenSSL/openssl.cnf

 

openssl req -new -sha256 -key domain.key -subj "/" \

  -reqexts SAN -config <(cat /etc/ssl/openssl.cnf \

  <(printf "[SAN]\nsubjectAltName=DNS:foo.com,DNS:www.foo.com"))

 

方法二:java下的keytool生成多域名证书的CSR

keytool -genkeypair -dname "CN=example.com"  -keyalg RSA  -alias example -keypass 123456 -keystore example.jks  -storepass 123456 -validity 3650

 

keytool -certreq -keyalg RSA -keystore example.jks -storepass 123456 -alias example -ext san=dns:www.example.com -file example.csr

 

第二步:将CSR提交给CA去签名

 

第三步:将签名结果、中间证书和根证书配置到服务器上,或先导入到keystore中,再把keystore配置到服务器上。

 

注意:

有人声称可以在dname中配置多个CN来制作多域名证书,经过测试,这个方法是行不通的,在导入签名结果后,只有第一个CN生效。

 

参考资料:

https://gethttpsforfree.com/

http://serverfault.com/questions/488003/keytool-serveralternatename

猜你喜欢

转载自epy.iteye.com/blog/2289959