升级openssl提升网站的ssl等级

今天查了一下服务器的openssl版本,是1.0.2k 是2017年的版本。而最新的正式版是1.1.1d。关键是1.1.1开始支持TLS1.3。没有理由不升级。

使用以下命令可查询openssl版本

openssl -version

升级过程也很简单,参考这篇教程即可。

升级完成后,我们需要修改nginx的配置文件。参考下列代码修改:

# generated 2019-12-30, https://ssl-config.mozilla.org/#server=nginx&server-version=1.17.0&config=intermediate&openssl-version=1.1.1d
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
    ssl_certificate /path/to/signed_cert_plus_intermediates;
    ssl_certificate_key /path/to/private_key;
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
    ssl_session_tickets off;

    # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam.pem
    ssl_dhparam /path/to/dhparam.pem;

    # intermediate configuration
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;

    # OCSP stapling
    # ssl_stapling on;
    # ssl_stapling_verify on;

    # verify chain of trust of OCSP response using Root CA and Intermediate certs
    # ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

    # replace with the IP address of your resolver
    # resolver 127.0.0.1;
}

以上文件来自mozilla的推荐配置。大家可以按照自己的配置自定义。

其中需要注意的是:

ssl_dhparam /path/to/dhparam.pem

关于dhparam:

dh(Diffie-Hellman)是著名的密钥交换协议,或称为密钥协商协议,它可以保证通信双方安全地交换密钥。但注意,它不是加密算法,所以不提供加密功能,仅仅只是保护密钥交换的过程。在openvpn中就使用了该交换协议。

需要我们通过下列语句主动生成dhparam.pem文件。目录可自主替换。

openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

一般用不到的我已经注释掉,例如OCSP 和 resolver。用來在線認證證書。

  1. whois说道:

    到myssl测试 拿到9分

发表评论