makdir -p /data/cert cd /data/cert openssl genrsa -des3 -out server.key 2048
效果以下,會讓你輸入密碼並確認密碼記住後邊有用。shell
Generating RSA private key, 2048 bit long modulus ......................................................................................................................+++ ..........+++ e is 65537 (0x10001) Enter pass phrase for server.key: Verifying - Enter pass phrase for server.key:
openssl req -new -key server.key -out server.csr
效果以下,填寫上邊的密碼,而後填寫我的信息,能夠隨便天寫ui
[root@zjdk cert]# openssl req -new -key server.key -out server.csr Enter pass phrase for server.key: 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. ----- # 國家CN Country Name (2 letter code) [XX]:CN # 省 State or Province Name (full name) []:beijing # 城市 Locality Name (eg, city) [Default City]:beijing # 組織名稱 Organization Name (eg, company) [Default Company Ltd]:xxxx # 單位名稱 Organizational Unit Name (eg, section) []:xxxx # 域名 Common Name (eg, your name or your server's hostname) []:crazyk.com.cn # 郵箱 Email Address []:code_dking@163.com Please enter the following 'extra' attributes to be sent with your certificate request # 不須要,剩下的兩個直接回車就能夠 A challenge password []: An optional company name []:
cp server.key server.key.org
#轉換爲證書 openssl rsa -in server.key.org -out server.key
效果以下,這個仍是須要輸入最開始填寫的密碼code
[root@zjdk cert]# openssl rsa -in server.key.org -out server.key Enter pass phrase for server.key.org: writing RSA key
#給證書籤名 openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
效果以下,表示成功,完結撒花orm
[root@zjdk cert]# openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt Signature ok subject=/C=cn/ST=beijing/L=beijing/O=xx/OU=cre.com/CN=cer.com/emailAddress=code_dking.com Getting Private key