Let’s encrypt SSL-sertifikaatin asennus Ubuntu 20.04 LTS

Let’s Encrypt SSL-sertifikaatti

Let’s Encrypt on ilmainen, automaattinen ja avoin SSL-sertifikaatti varmentaja. Sertifikaatti on voimassa 90 päivää.

SSL-sertifikaatin asennuksen valmistelu Apache2 palvelimeen

Aloitetaan SSL-sertifikaatin asennuksen valmistelu asentamalla ensin certbot ohjelmisto Ubuntuun. Anna seuraava komento Ubuntu konsolissa.

sudo apt install certbot python3-certbot-apache

Certbot ohjelmisto on nyt asennettu Ubuntu palvelimeen. Varmistetaan vielä, että Apachen virtuaalipalvelimen asetustiedostosta seuraavat asetukset. Tiedostossa pitää olla oikea verkkotunnus määriteltynä koska certbot ohjelmisto etsii sieltä oikeaa verkkotunnusta SSL-sertifikaattia varten. Anna seuraava komento.

sudo vim /etc/apache2/sites-available/verkkotunnus.fi.conf

Etsi Apachen virtuaalipalvelimen asetuksista seuraavat kohdat tai jos niitä ei ole niin lisää ne virtual host asetuksiin.

ServerName verkkotunnus.fi 
ServerAlias www.verkkotunnus.fi

Tallenna ja sulje tiedosto. Seuraavaksi tarkistetaan vielä, että Apachen asetukset ovat kunnossa. Anna seuraava komento.

sudo apache2ctl configtest

Mikäli kaikki on kunnossa niin komento tulostaa seuraavan tekstin.

Syntax OK

Käynnistetään vielä Apache palvelin uudelleen, jotta tekemäsi muutokset tulevat voimaan. Anna seuraavaksi komento.

sudo systemctl reload apache2

Varmistetaan vielä lopuksi, että olet myös sallinut liikenteen portteihin 80 ja 443 Ubuntun ufw palomuurissa. Voit tarkistaa palomuurin avoinna olevat portit seuraavasti.

sudo ufw status

Komennon suorittamisen jälkeen sinun pitäisi nähdä nämä rivit mikäli portit ovat jo valmiiksi avoinna.

80 ALLOW Anywhere
443 ALLOW Anywhere

Voit avata tarvittavat porttit 80 ja 443 ufw palomuuriin seuraavasti.

sudo ufw allow 443 comment "https"
sudo ufw allow 80 comment "http"
Let’s Encrypt SSL-sertifikaatti

SSL-sertifikaatin hankkiminen Apache2 palvelimeen

Aloitetaan SSL-srtifikaatin luominen ja hankkiminen. Aloita SSL-sertifikaatin luonti seuraavalla komennolla.

sudo certbot --apache

Seuraavaksi sinulta kysytään sähköpostiosoitetta, johon sinun pitää antaa toimiva sähköpostiosoite. Hyväksy sähköpostiosoite ja paina lopuksi enter.

Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected:
Authenticator apache, Installer apache Enter email address 
(used for urgent renewal and security notices) 
 
(Enter 'c' to cancel): posti@verkkotunnus.fi

Hyväksytään käyttöehdot. Valitse vaihtoehto A.

Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. 
You must agree in order to register with the ACME 
server at https://acme-v02.api.letsencrypt.org/directory 

(A)gree/(C)ancel: A

Sinulta kysytään vielä, että haluatko jakaa sähköpostisi Electronic Frontier -säätiön kanssa saadaksesi uutisia ja muuta tietoa heidän toiminnastaan. Voit itse päättää haluatko saada näitä uutisia ja tietoja. Tässä esimerkissä vastaamme kysymykseen N.

Would you be willing to share your email address with the Electronic Frontier Foundation, a founding 
partner of the Let's Encrypt project and the non-profit organization that develops Certbot? 
We'd like to send you email about our work 
encrypting the web, EFF news, campaigns, and 
ways to support digital freedom. 

(Y)es/(N)o: N

Nyt sinun pitää valita mille verkkotunnukselle haluat ottaa https osoitteen käyttöön. Älä valitse tässä vaiheessa mitään vaan paina ainostaan enter. Silloin sinulle tulee verkkotunnus.fi sekä www.verkkotunnus.fi osoitteelle SSL käyttöön.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
 
1: verkkotunnus.fi
2: www.verkkotunnus.fi
 
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):

Certbot luo automaattisesti uuden verkkotunnus.fi-le-ssl.conf tiedoston apache2 palvelimelle.

Obtaining a new certificate Performing the following 
challenges: http-01 challenge for verkkotunnus.fi http-01 
challenge for www.verkkotunnus.fi Enabled Apache rewrite module Waiting for verification… 
Cleaning up challenges Created an SSL vhost 
at /etc/apache2/sites-available/verkkotunnus.fi-le-ssl.conf 
Enabled Apache socache_shmcb module Enabled Apache ssl module 
Deploying Certificate to VirtualHost /etc/apache2/sites-available/verkkotunnus.fi-le-ssl.conf 
Enabling available site: /etc/apache2/sites-available/verkkotunnus.fi-le-ssl.conf 
Deploying Certificate to VirtualHost /etc/apache2/sites-available/verkkotunnus.fi-le-ssl.conf


Sinua pyydetään valitsemaan vaihtoehto, että uudelleen ohjataanko kaikki HTTP-liikenne uudelleen HTTPS-liikenteeksi. Valitse vaihtoehto 2.

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Tämän jälkeen sinun SSL-sertifikaatti on luotu ja lisätty Apache2 palvelimeen.

Congratulations! You have successfully enabled https://verkkotunnus.fi and
https://www.verkkotunnus.fi
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=verkkotunnus.fi
https://www.ssllabs.com/ssltest/analyze.htmld=www.verkkotunnus.fi

IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/verkkotunnus.fi/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/verkkotunnus.fi/privkey.pem
Your cert will expire on 2020-12-07. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew all of
your certificates, run "certbot renew"
Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
Donating to EFF:                    https://eff.org/donate-le 
Let's encrypt SSL-sertifikaatin uusiminen

Certbotin automaattinen Let’s encrypt SSL-sertifikaatin uusiminen

Let’s Encrypt -sertifikaatit ovat voimassa ainoastaan 90 päivää. Tämän tarkoituksena on kannustaa käyttäjiä automatisoimaan varmenteen uusimisprosessinsa ja varmistamaan, että väärin käytetyt varmenteet tai varastetut avaimet vanhenevat nopeasti. Tarkista vielä, että SSL-sertifikaatin automaattinen uusiminen on käytössä. Anna seuraava komento.

sudo systemctl status certbot.timer

Nyt sinun pitäsisi saada ilmotus, että sertifikaatin automaattinen uusimen on käytössä

● certbot.timer - Run certbot twice daily
      Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
      Active: active (waiting) since Thu 2020-12-10 22:02:51 EET; 2 days ago
     Trigger: Sun 2020-12-13 09:01:43 EET; 9h left
    Triggers: ● certbot.service
 Dec 10 22:02:51 www systemd[1]: Started Run certbot twice daily.

Seuraavaksi voit vielä kokeilla sen, että SSL-sertifikaatin uusimen varmasti onnistuu. Anna vielä komento.

sudo certbot renew --dry-run

Sinun pitäsisi saada seuraava ilmoitus.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
 
Processing /etc/letsencrypt/renewal/verkkotunnus.fi.conf
 
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for verkkotunnus.fi
http-01 challenge for www.verkkotunnus.fi
Waiting for verification…
Cleaning up challenges
 
new certificate deployed with reload of apache server; fullchain
is
/etc/letsencrypt/live/verkkotunnus.fi/fullchain.pem
 
 
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)
Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/verkkotunnus.fi/fullchain.pem (success)
 ** DRY RUN: simulating 'certbot renew' close to cert expiry
 **          (The test certificates above have not been saved.)
 

Kaikki on nyt kunnossa. Olet nyt asentanut let’s encrypt SSL-sertifikaatin Apache2 palvelimeen.

JAA ARTIKKELI




Vastaa

Sähköpostiosoitettasi ei julkaista. Pakolliset kentät on merkitty *