OpenSSL generates certificates
[Email protected] key]$ pwd
/app/nginx/key
- generate private key
OpenSSL genrsa-out server.key 2048
- Generate certificate request
OpenSSL Req-new-key server.key-out SERVER.CSR
- Fill in information
[[email protected] key]$ OpenSSL req-new-key server.key-out server.csryou is about to B E asked to enter information that'll be incorporatedinto your certificate request. What's about-to-enter is called a distinguished Name or a DN. There is quite a few fields but can leave some blankfor some fields there would be a default value,if you enter '. ', t He field would be a left blank.-----Country Name (2 letter code) [Xx]:cnstate or province name (full name) []:gdlocality name (eg, city) [Default city]:gzorganization name (eg, company) [Default company ltd]:aiorganizational Unit Name (eg, section) []:aicommo n name (eg, your Name or your server ' s hostname) []:112.96.28.206email Address []:
Please enter the following ' extra ' attributes
To is sent with your certificate request
A Challenge Password []:
An optional company name []:
[Email protected] key]$
[[email protected] key]$ ls
Old SERVER.CSR Server.key
4. 备份一份服务器密钥文件cp server.key server.key.org5. 去除文件口令openssl rsa -in server.key.org -out server.key6. 生成证书文件server.crtopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
[email protected] key]$ OpenSSL rsa-in server.key.org-out server.key
Writing RSA Key
[Email protected] key]$
[email protected] key]$ OpenSSL x509-req-days 365-in server.csr-signkey server.key-out server.crt
Signature OK
subject=/c=cn/st=gd/l=gz/o=ai/ou=ai/cn=112.96.28.206
Getting Private Key
一般只需三步:1. openssl genrsa -out server.key 20482. openssl req -new -key server.key -out server.csr3. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt关于密码:openssl genrsa -out server.key 2048 不需要密码。openssl genrsa -des3 -out server.key 2048 需要密码。https://www.jianshu.com/p/9523d888cf77关于域名:用openssl,域名可以不输;用keystore,必须输入。
To generate an SSL (HTTPS) certificate using OpenSSL