在本身的虚拟机生成ssl 须要用到openssl工具linux
[root@hf-01 ~]# cd /usr/local/nginx/conf/ [root@hf-01 conf]#
[root@hf-01 conf]# rpm -qf `which openssl` openssl-1.0.2k-8.el7.x86_64 [root@hf-01 conf]#
[root@hf-01 conf]# openssl genrsa -des3 -out tmp.key 2048 Generating RSA private key, 2048 bit long modulus .......+++ ......................................................................+++ e is 65537 (0x10001) Enter pass phrase for tmp.key: //输入密码 Verifying - Enter pass phrase for tmp.key: //再次输入密码 [root@hf-01 conf]#
[root@hf-01 conf]# openssl rsa -in tmp.key -out gurui.key Enter pass phrase for tmp.key: //输入tmp.key的密码 writing RSA key [root@hf-01 conf]#
[root@hf-01 conf]# rm -f tmp.key [root@hf-01 conf]#
[root@hf-01 conf]# openssl req -new -key gurui.key -out gurui.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:cn //国家,2个字母 State or Province Name (full name) []:JiangSu //省或州 Locality Name (eg, city) [Default City]:YanCheng //城市 Organization Name (eg, company) [Default Company Ltd]:han //公司 Organizational Unit Name (eg, section) []:han //组织 Common Name (eg, your name or your server’s hostname) []:hanfeng //您的主机名 Email Address []:han1118feng@163.com //邮箱 Please enter the following ‘extra’ attributes to be sent with your certificate request A challenge password []:hanfeng //设置密码 An optional company name []: //一个可选的公司名称 用请求证书文件和私钥文件,生成一个公钥 [root@hf-01 conf]#
[root@hf-01 conf]# openssl x509 -req -days 365 -in gurui.csr -signkey gurui.key -out gurui.crt Signature ok subject=/C=11/ST=BEIJING/L=BeiJing/O=hanfeng/OU=hanfeng/CN=hanfeng/emailAddress=han1118fem\x08 Getting Private key [root@hf-01 conf]#