生成自签名SAN/UCC证书

2 篇文章 0 订阅
2 篇文章 0 订阅

一、环境介绍
操作系统:
CentOS Linux release 7.6.1810 (Core)
openssl 版本:
OpenSSL 1.0.2k-fips 26 Jan 2017
二、生成自签名证书过程
以 opssl.com为例子

# 建立工作目录
[root@hsspuat ~]# mkdir /opt/ssl_san && cd /opt/ssl_san
[root@hsspuat ssl_san]# mkdir ca cert && cd ca
   # 生成CA私钥
[root@hsspuat ca]# openssl genrsa -out ca.key 2048
Generating RSA private key, 2048 bit long modulus
....................................................................+++
....+++
e is 65537 (0x10001)
# 生成CA证书
[root@hsspuat ca]# openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/C=CN/ST=HuBei/L=WuHan/O=opssl/OU=uat/emailAddress=uat@com.cn"
    # 生成nginx私钥
[root@hsspuat ca]# cd ../cert/
[root@hsspuat cert]# openssl genrsa -out opssl.com_san_key.key 2048
Generating RSA private key, 2048 bit long modulus
...................................................................................................................+++
..................................+++
e is 65537 (0x10001)

# 生成san证书配置文件,不同证书,需要创建用对应的san配置,如网关(opssl.com)的需要生成san.cfg
[root@hsspuat cert]# vim san.cfg
[ req ]
default_bits       = 2048
default_keyfile    = opssl.com_san_key.key # name of the keyfile
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 = HuBei
localityName                = Locality Name (eg, city)
localityName_default        = WuHan
organizationName            = Organization Name (eg, company)
organizationName_default    = opssl
commonName                  = Common Name (e.g. server FQDN or YOUR name)
commonName_max              = 64
organizationalUnitName      = Organizational Unit Name (eg, section)
organizationalUnitName_default  = uat
commonName          = Common Name (eg, YOUR name)
commonName_default      = opssl.com
commonName_max          = 64
emailAddress            = Email Address
emailAddress_max        = 64
emailAddress_default    = uat@com.cn
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = opssl.com
DNS.2 = localhost
IP.1 = 127.0.0.1
IP.2 = 10.11.11.11 # 自己的ip
   
 
# 生成请求(csr)文件,如果要购买权威机构证书的话,将csr文件提交给权威机构即可。
[root@hsspuat cert]# openssl req -new -key opssl.com_san_key.key -out opssl.com_san_csr.csr  -config san.cfg  -subj "/C=CN/ST=HuBei/L=WuHan/O=opssl/OU=uat/CN=opssl.com"
# 检查生成的请求文件。
[root@hsspuat cert]# openssl req -in opssl.com_san_csr.csr -text -noout | grep DNS
                DNS:opssl.com, DNS:localhost, IP Address:127.0.0.1, IP Address:10.11.11.11
# 用自己的CA证书签名(crt/cer)
#openssl x509 -req -in opssl.com_san_csr.csr -CA ../ca/ca.crt -CAkey ../ca/ca.key -CAcreateserial -out opssl.com_san_crt.crt -extensions req_ext -extfile san.cfg
#openssl x509 -req -in opssl.com_san_csr.csr -CA ../ca/ca.crt -CAkey ../ca/ca.key -CAcreateserial -out opssl.com_san_cer.cer -extensions req_ext -extfile san.cfg
# 检查签名的证书
#openssl x509 -in opssl.com_san_crt.crt -text -noout | grep DNS
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

金色大地。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值