通配符SSL证书的部署主要分为**申请/获取证书**和**服务器部署**两个阶段。下面我写一下详细的步骤和注意事项:

第一阶段:申请与获取证书

1.  生成证书签名请求(CSR)

私钥生成:

bash

openssl  genrsa  -out  example.key  2048

生成CSR(注意通配符格式):

bash

openssl  req  -new  -key  example.key  -out  example.csr

关键字段:Common  Name  (CN)必须填写通配符域名,如:example.com(覆盖所有同级子域名,但不包括根域名)。

附加:可添加Subject  Alternative  Names  (SANs) 扩展覆盖根域名(如  :example.com)。

2.  提交CSR到证书颁发机构(CA)

选择可信CA(如Let's  Encrypt、DigiCert、Sectigo等)。

根据CA要求完成**域名验证**(通常通过DNS添加TXT记录或HTTP文件验证)。

付费证书需提交订单并上传CSR。

3.  下载证书文件

证书包通常包含:

域名证书(crt`或  pem)

中间证书链(CA  Bundle)

根证书(通常已内置在浏览器中

第二阶段:服务器部署

Nginx  配置示例

nginx

server  {

listen  443  ssl  http2;

server_name  *.example.com  example.com;

ssl_certificate            /path/to/certificate_chain.crt;    证书+中间链

ssl_certificate_key    /path/to/example.key;  私钥

强化安全配置(可选但建议)

ssl_protocols  TLSv1.2  TLSv1.3;

ssl_ciphers  ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512;

ssl_prefer_server_ciphers  off;

其他配置..

Apache  配置示例

apache

<VirtualHost  *:443>

ServerName  example.com

ServerAlias  *.example.com

SSLEngine  on

SSLCertificateFile            /path/to/certificate.crt

SSLCertificateKeyFile      /path/to/example.key

SSLCertificateChainFile  /path/to/intermediate.crt

安全强化配置

SSLProtocol                          all  -SSLv3  -TLSv1  -TLSv1.1

SSLCipherSuite                    ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256

</VirtualHost>

Tomcat  配置示例**(使用keystore)

bash

将证书转换为Java  Keystore格式

openssl  pkcs12  -export  -in  certificate.crt  -inkey  example.key  -out  keystore.p12

在  server.xml  中配置:

xml

<Connector  port="8443"  protocol="org.apache.coyote.http11.Http11NioProtocol"

SSLEnabled="true">

<SSLHostConfig>

<Certificate  certificateKeystoreFile="/path/to/keystore.p12"

certificateKeystorePassword="密码"

type="RSA"  />

</SSLHostConfig>

</Connector>

关键注意事项

1.  通配符范围:

example.com`  仅覆盖同级子域名(如  `blog.example.com`),不包含多级子域名(如  dev.blog.example.com)。

  如需多级子域名,可申请 example.com(部分CA支持,价格较高)。

2.  根域名覆盖:

通配符证书默认不包含根域名,如需同时保护  example.com,建议:

申请时添加根域名到SAN扩展。

或单独为根域名配置证书。

3.  安全强化:

启用HTTP严格传输安全(HSTS)  强制HTTPS。

定期更新密钥和证书(通配符证书有效期通常为1年)。

4.  自动化工具:

使用 Let's  Encrypt  +  Certbot可自动化申请和续期:

bash

certbot  certonly  --manual  --preferred-challenges=dns  -d  *.example.com

验证与测试

1.  检查证书链完整性:

bash

openssl  verify  -CAfile  intermediate.crt  certificate.crt

2.  在线工具:

使用  [SSL  Labs](https://www.ssllabs.com/ssltest/)  测试配置安全性。

检查浏览器中的证书信息是否包含  example.com。

常见问题有以下几点:

浏览器警告:通常因中间证书缺失引起,需合并证书链。

私钥保护:私钥文件应严格限制权限(如  :chmod  400  example.key)。

多服务器部署:同一通配符证书可在多台服务器使用,但需注意私钥分发

通过以上步骤,应该能成功部署通配符SSL证书。在根据具体服务器环境和需求调整配置细节。