Kā iespējot TLS 1.3 Apache un Nginx


TLS 1.3 ir protokola Transport Layer Security (TLS) jaunākā versija, un tā ir balstīta uz esošajām 1.2 specifikācijām ar atbilstošu IETF standartu: RFC 8446. Tas nodrošina spēcīgāku drošību un augstākas veiktspējas uzlabojumus salīdzinājumā ar iepriekšējiem.

Šajā rakstā mēs parādīsim detalizētu rokasgrāmatu, lai iegūtu derīgu TLS sertifikātu un iespējotu jaunāko TLS 1.3 versijas protokolu savā domēnā, kas mitināts Apache vai Nginx tīmekļa serveros.

  • Apache versija 2.4.37 vai jaunāka.
  • Nginx versija 1.13.0 vai jaunāka.
  • OpenSSL 1.1.1 vai jaunāka versija.
  • Derīgs domēna nosaukums ar pareizi konfigurētiem DNS ierakstiem.
  • Derīgs TLS sertifikāts.

Instalējiet TLS sertifikātu vietnē Let’s Encrypt

Lai no Let’s Encrypt iegūtu bezmaksas SSL sertifikātu, Linux sistēmā ir jāinstalē Acme.sh klients un arī dažas nepieciešamās paketes, kā parādīts.

# apt install -y socat git  [On Debian/Ubuntu]
# dnf install -y socat git  [On RHEL/CentOS/Fedora]
# mkdir /etc/letsencrypt
# git clone https://github.com/Neilpang/acme.sh.git
# cd acme.sh 
# ./acme.sh --install --home /etc/letsencrypt --accountemail [email 
# cd ~
# /etc/letsencrypt/acme.sh --issue --standalone --home /etc/letsencrypt -d example.com --ocsp-must-staple --keylength 2048
# /etc/letsencrypt/acme.sh --issue --standalone --home /etc/letsencrypt -d example.com --ocsp-must-staple --keylength ec-256

PIEZĪME. Iepriekš komandā aizstājiet example.com ar savu īsto domēna nosaukumu.

Kad esat instalējis SSL sertifikātu, varat turpināt tālāk iespējot TLS 1.3 savā domēnā, kā paskaidrots tālāk.

Nginx iespējot TLS 1.3

Kā jau minēju iepriekšējās prasībās, TLS 1.3 tiek atbalstīts, sākot ar Nginx 1.13 versiju. Ja izmantojat vecāku Nginx versiju, vispirms jāatjaunina uz jaunāko versiju.

# apt install nginx
# yum install nginx

Pārbaudiet Nginx versiju un OpenSSL versiju, pret kuru Nginx tika kompilēts (pārliecinieties, ka nginx versija ir vismaz 1.14 un openssl 1.1.1).

# nginx -V
nginx version: nginx/1.14.1
built by gcc 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC) 
built with OpenSSL 1.1.1 FIPS  11 Sep 2018
TLS SNI support enabled
....

Tagad sāciet, iespējojiet un pārbaudiet nginx instalēšanu.

# systemctl start nginx.service
# systemctl enable nginx.service
# systemctl status nginx.service

Tagad, izmantojot iecienīto redaktoru, atveriet failu nginx vhost konfigurācija /etc/nginx/conf.d/example.com.conf .

# vi /etc/nginx/conf.d/example.com.conf

un atrodiet ssl_protocols direktīvu un rindas beigās pievienojiet TLSv1.3, kā parādīts zemāk

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

  server_name example.com;

  # RSA
  ssl_certificate /etc/letsencrypt/example.com/fullchain.cer;
  ssl_certificate_key /etc/letsencrypt/example.com/example.com.key;
  # ECDSA
  ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.cer;
  ssl_certificate_key /etc/letsencrypt/example.com_ecc/example.com.key;

  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
  ssl_prefer_server_ciphers on;
}

Visbeidzot, pārbaudiet konfigurāciju un atkārtoti ielādējiet Nginx.

# nginx -t
# systemctl reload nginx.service

Apache iespējojiet TLS 1.3

Sākot ar Apache 2.4.37, varat izmantot TLS 1.3 priekšrocības. Ja izmantojat vecāku Apache versiju, vispirms jāatjaunina uz jaunāko versiju.

# apt install apache2
# yum install httpd

Pēc instalēšanas jūs varat pārbaudīt Apache un OpenSSL versiju, ar kuru Apache tika kompilēts.

# httpd -V
# openssl version

Tagad sāciet, iespējojiet un pārbaudiet nginx instalēšanu.

-------------- On Debian/Ubuntu -------------- 
# systemctl start apache2.service
# systemctl enable apache2.service
# systemctl status apache2.service

-------------- On RHEL/CentOS/Fedora --------------
# systemctl start httpd.service
# systemctl enable httpd.service
# systemctl status httpd.service

Tagad atveriet Apache virtuālā resursdatora konfigurācijas failu, izmantojot iecienīto redaktoru.

# vi /etc/httpd/conf.d/vhost.conf
OR
# vi /etc/apache2/apache2.conf

un atrodiet ssl_protocols direktīvu un rindas beigās pievienojiet TLSv1.3, kā parādīts zemāk.

<VirtualHost *:443>
SSLEngine On

# RSA
ssl_certificate /etc/letsencrypt/example.com/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example.com/example.com.key;
# ECDSA
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.cer;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/example.com.key;

ssl_protocols TLSv1.2 TLSv1.3
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
ssl_prefer_server_ciphers on;
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem

     ServerAdmin [email 
     ServerName www.example.com
     ServerAlias example.com
    #DocumentRoot /data/httpd/htdocs/example.com/
    DocumentRoot /data/httpd/htdocs/example_hueman/
  # Log file locations
  LogLevel warn
  ErrorLog  /var/log/httpd/example.com/httpserror.log
  CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/example.com/httpsaccess.log.%Y-%m-%d 86400" combined
</VirtualHost>

Visbeidzot, pārbaudiet konfigurāciju un atkārtoti ielādējiet Apache.

-------------- On Debian/Ubuntu -------------- 
# apache2 -t
# systemctl reload apache2.service

-------------- On RHEL/CentOS/Fedora --------------
# httpd -t
# systemctl reload httpd.service

Pārbaudiet, vai vietne izmanto TLS 1.3

Kad esat to konfigurējis, izmantojot tīmekļa serveri, varat pārbaudīt, vai jūsu vietne rokasspiediena protokolā TLS 1.3 izmanto Chrome pārlūka izstrādes rīkus Chrome 70+ versijā.

Tas ir viss. Jūs esat veiksmīgi iespējojis TLS 1.3 protokolu savā domēnā, kas mitināts Apache vai Nginx tīmekļa serveros. Ja jums ir kādi jautājumi par šo rakstu, droši jautājiet zemāk esošajā komentāru sadaļā.