这里说下Linux 系统怎么通过生成 证书。

 

首先执行如下命令生成一个4096位的key

openssl genrsa -des3 -out hupohost.key 4096
然后他会要求你输入这个key文件的密码。不推荐输入。因为以后要给使用。每次reload nginx配置时候都要你验证这个PAM密码的。

 

由于生成时候必须输入密码。你可以输入后 再删掉

mv .key xxx.key
openssl rsa -in xxx.key -out hupohost.key
 -rm xxx.key

 

然后根据这个key文件生成证书请求文件

openssl req -new -key hupohost.key -out hupohost.csr
以上命令生成时候要填很多东西 一个个看着写吧(可以随便,毕竟这是自己生成的证书)

 

最后根据这2个文件生成证书文件

openssl x509 -req -days 3650 -in hupohost.csr -signkey hupohost.key -out hupohost.crt
这里3650是证书有效期 推荐3650哈哈。这个大家随意。最后使用到的文件是key和crt文件。

 

如果需要用 可以用以下命令生成
openssl pkcs12 -export -inkey hupohost.key -in hupohost.crt -out hupohost.pfx

 

在需要使用证书的nginx配置文件的server节点里加入以下配置就可以了

ssl on;
ssl_certificate /home/hupohost.crt;
ssl_certificate_key /home/hupohost.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
然后重启nginx就大功告成了

 

最重要的是,访问是https进行访问

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;
}
端口一定是443端口
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。