在本身的虛擬機生成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]#