🢂Certyfikat SSL na localhost z Let’s Encrypt i Certbot

Serwery internetowe uzyskują swoje certyfikaty od zaufanych podmiotów trzecich zwanych urzędami certyfikacji (CA). Poniżej instrukcja jak użyć Certbota.

Wstęp

Certyfikat SSL na localhost, to jest to ważny element, jeśli chcesz mieć pewność, że Twoja aplikacja działa poprawnie z SSL/TLS. Certbot to łatwy w użyciu klient, który pobiera certyfikat z Let’s Encrypt — otwartego urzędu certyfikacji uruchomionego przez EFF, Mozillę i innych — i wdraża go na serwerze internetowym.

Instalacja

Najlepszym sposobem na instalacje jest skorzystanie z interaktywnego przewodnika znajdującego się na stronie Certbota. Szczegółowe instrukcje znajdziesz tutaj: https://certbot.eff.org/instructions

Generowanie certyfikatu dla Apache

Za pomocą poniższego polecenia Certbot łączy się z Let's Encrypt, aby uzyskać certyfikat SSL dla Twojej domeny. Robi to, sprawdzając, czy masz kontrolę nad domeną, zazwyczaj poprzez automatyczne umieszczenie pliku w katalogu .well-known/acme-challenge na Twoim serwerze.

sudo certbot --apache

wynik polecenia:

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: dev1.evillage.pl
2: dev2.evillage.pl
3: dev3.evillage.pl
...
11: devapp.localhost
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):

Uwaga

Musisz mieć domenę podpiętą pod IP. Dla domeny devapp.localhost potrzymasz błąd jak na poniższym przykłądzie

Requesting a certificate for devapp.localhost
An unexpected error occurred:
Invalid identifiers requested :: Cannot issue for "devapp.localhost": Domain name does not end with a valid public suffix (TLD)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.