[root@centos7 conf]# openssl rsa -in tmp.key -out testssl.key
Enter pass phrase for tmp.key: 输入第2步的密码
4、删除密钥文件:
[root@centos7 conf]# rm -f tmp.key
5、生成证书请求文件
需要拿这个文件和私钥一起生产公钥文件:
[root@centos7 conf]# openssl req -new -key testssl.key -out testssl.csr
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:GD
Locality Name (eg, city) [Default City]:GZ
Organization Name (eg, company) [Default Company Ltd]:FC
Organizational Unit Name (eg, section) []:FC
Common Name (eg, your name or your server's hostname) []:testssl
Email Address []:admin@admin.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:123456
6、
[root@centos7 conf]# ls testssl.*
testssl.csr testssl.key
7、创建公钥
[root@centos7 conf]# openssl x509 -req -days 365 -in testssl.csr -signkey testssl.key -out testssl.crt
Signature ok
subject=/C=CN/ST=GD/L=GZ/O=FC/OU=FC/CN=testssl/emailAddress=admin@admin.com
Getting Private key
You have new mail in /var/spool/mail/root
[root@centos7 conf]# ls testssl.*
testssl.crt testssl.csr testssl.key
8、nginx配置ssl
[root@centos7 vhost]# vi ssl.conf
server
{
listen 443;
server_name testssl.com;
index index.html index.php;
root /data/wwwroot/ssl.com;
ssl on;
#开启ssl
ssl_certificate testssl.crt;
#配置公钥
ssl_certificate_key testssl.key;
#配置私钥
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#配置协议
}