Here's how Linux systems generate certificates through the OpenSSL command.
First, execute the following command to generate a 4,096-bit key
The code is as follows |
Copy Code |
OpenSSL genrsa-des3-out hupohost.key 4096 |
Then he will ask you to enter the password for this key file. Input is not recommended. Because in the future to be used for nginx. Every time reload Nginx configuration, you need to verify this Pam password.
The password must be entered at build time. You can type it and then delete it.
The code is as follows |
Copy Code |
MV Ssl.key Xxx.key OpenSSL rsa-in xxx.key-out Hupohost.key RM-RM Xxx.key
|
Then generate the certificate request file based on this key file
The code is as follows |
Copy Code |
OpenSSL Req-new-key hupohost.key-out HUPOHOST.CSR |
The above command generation to fill a lot of things to read and write it (you can casually, after all, this is the certificate of their own generation)
Finally, the CRT certificate file is generated based on these 2 files
The code is as follows |
Copy Code |
OpenSSL x509-req-days 3650-in hupohost.csr-signkey hupohost.key-out hupohost.crt |
Here 3650 is the certificate validity period recommendation 3650 haha. This is random. The last file to use is key and CRT files.
If you need to use a PFX you can use the following command to generate
The code is as follows |
Copy Code |
OpenSSL pkcs12-export-inkey hupohost.key-in hupohost.crt-out hupohost.pfx
|
Add the following configuration to the server node where you need to use the Nginx configuration file for the certificate
The code is as follows |
Copy Code |
SSL on; SSL_CERTIFICATE/HOME/HUPOHOST.CRT; Ssl_certificate_key/home/hupohost.key; Ssl_session_timeout 5m; Ssl_protocols SSLv2 SSLv3 TLSv1; Ssl_ciphers all:! Adh:! Export56:rc4+rsa:+high:+medium:+low:+sslv2:+exp; Ssl_prefer_server_ciphers on; |
and restart the Nginx.
Most importantly, access is HTTPS.
The code is as follows |
Copy Code |
server{ Listen 443; SSL on; SSL_CERTIFICATE/USR/LOCAL/NGINX/CONF/VHOST/SSL/HUPOHOST.CRT; Ssl_certificate_key/usr/local/nginx/conf/vhost/ssl/hupohos.key; }
|
Port must be 443 ports