Let’s Encrypt SSL/TLS-sertifikaatti ilmaiseksi ja vaivattomasti omille sivuille

Asensin Let’s Encrypt SSL-sertifikaatin DigitalOceanista vuokraamalleni Ubuntu 16.04.4 x64 pohjaiselle virtuaalipalvelimelle (1 CPU, 1GB RAM, 25GB Disk, FRA1). Webpalvelinohjelmiston virkaa palvelimella pyörittää Apache2. Tarkemmat tiedot konfiguraatiostani löytyy aiemmasta blogistani: https://markuspyharanta.wordpress.com/2018/05/02/osticket-asennus-ja-konfigurointi/.

Let’s Encryptiin liittyen, katso: https://letsencrypt.org/about/
Sertifikaatin asennus on helppoa varsinkin Certbottia käyttämällä: https://certbot.eff.org/. Kun menee certbotin sivustolle ja syöttää palvelimen järjestelmätiedot, antaa se suorat ohjeet asennukselle. Tämän oman palvelimeni tapauksessa asennus meni näin:

Lisäsin certbotin PPA:n (Personal Package Archiven) repo-listaani ja päivitin pakettivarastot. Sitten asensin certbotin python-certbot-apache -paketin.

$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-apache

Asennuksen jälkeen, ajoin komennon:

$ sudo sertbot --apache

Tuo komento hakee palvelimelleni sertifikaatin ja muokkaa automaattisesti Apachen konfiguraatiota sen käyttöönottamiseksi.

Minulta kysyttiin sähköpostiosoite ja minua pyydettiin hyväksymään käyttöehdot. Lisäksi kysyttiin, mille kaikille domain-nimille haluan ottaa HTTPS:n käyttöön.

Which names would you like to activate HTTPS for?
 -------------------------------------------------------------------------------
 1: markuspyharanta.com
 2: www.markuspyharanta.com
 -------------------------------------------------------------------------------
 Select the appropriate numbers separated by commas and/or spaces, or leave input
 blank to select all options shown (Enter 'c' to cancel):

Valitsin molemmat nimet painamalla tyhjää.

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

Sertifikaatti on nyt otettu käyttöön kaikille virtualhosteille.

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

Valitsin 2, eli aina käytetään HTTPS.

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

Valmista! Sertifikaatti vieläpä uusitaan automaattisesti Certbotin toimesta, ennen kuin se vanhenee. Muuten sertifikaatin päivittäminen pitäisi tehdä manuaalisesti 90 päivän välein. Automaattisen uusimisen toimivuuden voi testata ajamalla komennon:

sudo certbot renew --dry-run

Tulos:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
-------------------------------------------------------------------------------
 Processing /etc/letsencrypt/renewal/markuspyharanta.com.conf
 -------------------------------------------------------------------------------
 Cert not due for renewal, but simulating renewal for dry run
 Plugins selected: Authenticator apache, Installer apache
 Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
 Renewing an existing certificate
 Performing the following challenges:
 http-01 challenge for markuspyharanta.com
 http-01 challenge for www.markuspyharanta.com
 Waiting for verification...
 Cleaning up challenges
-------------------------------------------------------------------------------
 new certificate deployed with reload of apache server; fullchain is
 /etc/letsencrypt/live/markuspyharanta.com/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/markuspyharanta.com/fullchain.pem (success)
 ** DRY RUN: simulating 'certbot renew' close to cert expiry
 ** (The test certificates above have not been saved.)
 -------------------------------------------------------------------------------

Toimii.
cert1
cert2
cert3


Lähteet:

Let’s Encrypt:
https://letsencrypt.org/

Certbot:
https://certbot.eff.org/

Tarkemmat asennus ohjeet Apachelle ja Ubuntu 16.04:lle:
https://certbot.eff.org/lets-encrypt/ubuntuxenial-apache


TÄTÄ DOKUMENTTIA SAA KOPIOIDA JA MUOKATA GNU GENERAL PUBLIC LICENSE (VERSIO 3 TAI UUDEMPI) MUKAISESTI. HTTP://WWW.GNU.ORG/LICENSES/GPL.HTML
MARKUS PYHÄRANTA

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top