0x00 Background
Since the end support for TLS 1.0 and 1.1, SSL Labs has change its grade for sites which support them to B since 2020/01/31. Moreover, modern browsers like Chrome/FireFox/IE has deprecated support for them since first half of 2020. Therefore, it is time to migrate to TLS 1.2 or higher if your site is still using TLS 1.0 and 1.1.
0x01 How To
If you are using nginx config like following:
1 2 3 4 5 6 7 8 9 | server { listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate /path/to/signed_cert_plus_intermediates; ssl_certificate_key /path/to/private_key; ... } |
you should enable tls by default, but if you don’t specify the version, nginx will support TLS 1.0,1.1 and 1.2. And this will result in B grade in SSL Labs. The best practice to receive a A+ grade is following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | server { listen 443 ssl http2; listen [::]:443 ssl http2; 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 ssl_dhparam /path/to/dhparam; # 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; } |
this configuration add Diffie-Hellman public key, TLS 1.2, 1.3, safer ciphers, ssl_session_cache to nginx default configuration to provide more security and performance. And you may also notice that this configuration change ssl_session_timeout from 10m to 1d and ssl_session_ticket from on to off, 1d ssl_session_timeout will reuse ssl session as possible and setting ssl_session_ticket to off can avoid ssl protocol error caused by inconsistent setting of ssl_session_ticket of multiple sites on same server.
0x02 Additional Configuration
You can also enable HTTP Strict Transport Security and OCSP Stapling if you like to obtain more security, add these would not affect score on SSL Labs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | server { listen 80 default_server; listen [::]:80 default_server; return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; 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 ssl_dhparam /path/to/dhparam; # 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; } |
note that if you are using Let’s Encrypt cert, you should use ca.cer in ssl_trusted_certificate and fullchain.cer in ssl_certificate.
Moreover, previous configuration will help you get 100 points in Certificate and Protocol Support, but you can’t get full scores on Key Exchange and Cipher Strength, in case you want full scores on these 4 items, you can follow these steps:
- Replace dhparam with 4096 bit one;
1 | openssl dhparam -out /etc/nginx/ssl/dhparam.pem 4096 |
1 | ssl_dhparam ssl/dhparam.pem; |
- change ssl_chipers to AES256+EECDH:AES256+EDH:!aNULL;
- add ssl_ecdh_curve secp384r1;