建议先创建一个空目录,作为证书制作空间,后续所有操作都在该目录下进行。
[ req ]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = req_ext
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = cn
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = sc
localityName = Locality Name (eg, city)
localityName_default = cd
organizationName = Organization Name (eg, company)
organizationName_default = my
organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = as
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_max = 64
commonName_default = yang.com
[ req_ext ]
subjectAltName = @alt_names
# 此段落标题的方括号两边【没有空格】,只有同时配有IP和域名,才能在IP和域名访问时都成功识别。
[alt_names]
IP.1 = 192.168.50.62
DNS.1 = yang.com
DNS.2 = yang.net
openssl genrsa -out server.key 4096
CSR是Certificate Signing Request的英文缩写,即证书请求文件,也就是证书申请者在申请数字证书时由CSP(加密服务提供者)在生成私钥的同时也生成证书请求文件,证书申请者只要把CSR文件提交给证书颁发机构后,证书颁发机构使用其根证书私钥签名就生成了证书公钥文件,也就是颁发给用户的证书。
openssl req -new -sha256 -out server.csr -key server.key -config mySsl.conf
这里会要求输入一系列参数,可以选择不填直接回车。
openssl req -text -noout -in server.csr
应该可以看到:X509v3 Subject Alternative Name: DNS:my-project.site and Signature Algorithm: sha256WithRSAEncryption
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt -extensions req_ext -extfile mySsl.conf
生成带subjectAltName的ssl服务端证书【亲测有效】
原文:https://www.cnblogs.com/JaxYoun/p/12692574.html