# 创建私钥
输入密码创建,RSA密钥长度不能小于 2048。
openssl genrsa -des3 -out ca.key 2048
生成如下
Generating RSA private key, 2048 bit long modulus
.............................................+++
................................+++
e is 65537 (0x010001)
Enter pass phrase for ca.key:
Verifying - Enter pass phrase for ca.key:
# 20 年有效期
通过配置文件生成证书
openssl req -x509 -new -nodes -key ca.key -sha256 -days 7300 -out ca.crt -config ./ca.cnf
把此证书导入需要部署的PC中即可,以后用此CA签署的证书都可以使用
查看证书信息命令 openssl x509 -in ca.crt -noout -text
cd ..
# 此文件夹存放待签名的证书
mkdir certs && cd certs
openssl genrsa -out domain.key 2048
输出信息
Generating RSA private key, 2048 bit long modulus
openssl req -new -key domain.key -out domain.csr -config domain.cnf
# ssl证书有效期825天,自签名证书最长的有效期不能超过825天
openssl x509 -req -in domain.csr -out domain.crt -days 825 \
-CAcreateserial -CA ca.crt -CAkey ca.key \
-CAserial serial -extfile cert.ext
此步骤需要输入CA私钥的密码
查看签署的证书信息
root@ubuntu:# openssl x509 -in domain.crt -noout -text
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
使用CA验证一下证书是否通过
root@ubuntu:# openssl verify -CAfile ca.crt domain.crt
localhost.crt: OK