Dodawanie nowej domeny – katalog, konfiguracja Apache2, certbot
Kategoria: Certyfikaty
certbot – obsługa certyfiktatów
certbot installation
Przygotowanie – snap
Czytaj dalej certbot installation
Let’s Encrypt – nowy certyfikat
# certbot certonly --webroot -w /var/www/html/MYAPP/webroot -d MYDOMAIN.pl # certbot renew # certbot delete -d domena.pl
openssl – server req + podpis CA
Utworzenie requestu serwera (bez hasła dla klucza)
# openssl req -config openssl-server.cnf -newkey rsa:2048 -sha256 -nodes -out /etc/ssl/requests/h25.csr -keyout /etc/ssl/private/h25.pem -outform PEM
openssl – plik konfiguracyjny serwera openssl-server.cnf
# nano /etc/ssl/openssl-server.cnf
Czytaj dalej openssl – plik konfiguracyjny serwera openssl-server.cnf
openssl – certyfikat serwera self-signed – bez CA
Nowy certyfikat serwera: bez CA – na 3 lata – bez zaszyfrowanego klucza
# openssl req -newkey -x509 -nodes rsa:4096 -days 1089 -keyout /etc/ssl/private/serverkey.pem -out /etc/ssl/newcerts/servercert.pem
Weryfikacja
# openssl x509 -purpose -in /etc/ssl/newcerts/servercert.pem
Czytaj dalej openssl – certyfikat serwera self-signed – bez CA
openssl – plik konfiguracyjny CA – openssl-ca.cnf
openssl – utworzenie CA, i certyfikatu serwera
Utworzenie CA i certyfikat serwera
openssl – ciphers
# openssl ciphers -v
TLS_AES_256_GCM_SHA384 TLSv1.3 Kx=any Au=any Enc=AESGCM(256) Mac=AEAD
TLS_CHACHA20_POLY1305_SHA256 TLSv1.3 Kx=any Au=any Enc=CHACHA20/POLY1305(256) Mac=AEAD
....
LetsEncrypt – usage
/etc/apache2/sites-available/000-default.conf
<VirtualHost 156.111.131.212:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/h25
ServerName h25.pl
</VirtualHost>
# certbot certonly --webroot -w /var/www/html/h25 -d h25.pl
/etc/letsencrypt/live/h25.pl/fullchain.pem
/etc/letsencrypt/live/h25.pl/privkey.pem
# certbot renew
LetsEncrypt – rozszerzenie domeny
Można dodać/usunąć domenę do certyfikatu już istniejącego np. o nazwie example.com:
# certbot certonly --cert-name example.com -d example.org,www.example.org
Nowy certyfikat będzie zawierał teraz dwie nazwy example.org oraz www.example.org
LetsEncrypt – webroot
https://certbot.eff.org/docs/using.html
# certbot certonly --webroot -w /var/www/rewita/webroot -d tmp.rewita.pl -d crm.rewita.pl
Odnowienie certyfikatu
Odnowienie co 60 dni poprzez moduł wykorzystujący crona
Odnawia wszystkie certyfikaty, które zbliżają się do wygaśnięcia <= 30 dni do końca. Komendę można wydawać codziennie lub raz na tydzień, można dodać do crona.
# certbot renew
Tylko sprawdza działania –dry-run
# certbot renew --dry-run
Zmiana długości klucza z 2048 na 4096
# certbot renew --rsa-key-size 4096
Certyfikaty wildcard
DNS plugin musi być zainstalowany dla dostawcy dns
# certbot -a <dns-plugin> -i apache -d "*.example.com" -d example.com --server https://acme-v02.api.letsencrypt.org/directory
Ręczna konfiguracja certyfikatów
Ręczna konfiguracja certyfikatów:
# certbot certonly --authenticator standalone
Przed zainstalowaniem trzeba zatrzymać serwer ręcznie lub za pomocą skryptów:
# certbot certonly --authenticator standalone --pre-hook "apache2ctl -k stop" --post-hook "apache2ctl -k start"
Certbot
https://certbot.eff.org/lets-encrypt/debianstretch-apache
# apt-get install python-certbot-apache -t stretch-backports
# certbot --authenticator webroot --installer apache