openssn.cnf位置在
/usr/local/ssl/openssl.cnf
修改【CA_default】标签下的 dir为固定目录、
dir= /home/nieqq/openssl/ca
echo "01" >>/home/nieqq/openssl/ca/serial
执行以下命令生成CA密钥
openssl genrsa -des3 -out /home/nieqq/openssl/ca/private/cakey.pem 2048 -config /usr/local/ssl/openssl.cnf
执行以下命令生成CA证书请求
openssl req -new -key /home/nieqq/openssl/ca/private/cakey.pem -out /home/nieqq/openssl/ca/cacert.pem
执行以下命令自签根证书
openssl x509 -req -days 365 -in /home/nieqq/openssl/ca/cacert.pem -signkey /home/nieqq/openssl/ca/private/cakey.pem -out /home/nieqq/openssl/ca/cacert.crt
执行以下命令生成服务器密钥
openssl genrsa -des3 -passout pass:server1 -out /home/nieqq/openssl/ca/server.local.net.key.pem 2048
执行以下命令生成服务器证书请求
openssl req -new -days 365 -key /home/nieqq/openssl/ca/server.local.net.key.pem -out /home/nieqq/openssl/ca/server.local.net.req.pem
执行以下命签发服务器证书
openssl ca -in /home/nieqq/openssl/ca/server.local.net.req.pem -out /home/nieqq/openssl/ca/server.local.net.cer -config /usr/local/ssl/openssl.cnf
SAN证书支持多个域名共用同一个证书可以查看这里的介绍
生成密钥与(3、签发服务器证书)相同,可以执行以下命令生成
openssl genrsa -des3 -passout pass:server1 -out /home/nieqq/openssl/ca/util.local.net.key 2048
执行以下命令生成SAN证书请求
openssl req -new \
-sha256 \
-key /home/nieqq/openssl/ca/util.local.net.key \
-subj "/C=CN/ST=GUANGDONG/L=GUANGZHOU/O=ORG1/OU=ORG2/CN=*.local.net" \
-reqexts SAN \
-config <(cat /usr/local/ssl/openssl.cnf \
<(printf "[SAN]\nsubjectAltName=DNS:*.local.net,DNS:ubs.local.net,DNS:cnt.local.net,DNS:win10.local.net,DNS:win7.local.net,DNS:www.ubs.local.net,DNS:www.cnt.local.net,DNS:www.win10.local.net,DNS:www.win7.local.net")) \
-out /home/nieqq/openssl/ca/util.local.net.req
执行以下命签发SAN证书
openssl ca -in /home/nieqq/openssl/ca/util.local.net.req \
-md sha256 \
-extensions SAN \
-config <(cat /usr/local/ssl/openssl.cnf \
<(printf "[SAN]\nsubjectAltName=DNS:*.local.net,DNS:ubs.local.net,DNS:cnt.local.net,DNS:win10.local.net,DNS:win7.local.net,DNS:www.ubs.local.net,DNS:www.cnt.local.net,DNS:www.win10.local.net,DNS:www.win7.local.net")) \
-out /home/nieqq/openssl/ca/util.local.net.crt