lunes, 5 de junio de 2017

¿Cómo instalar un certificado SSL de Let's Encrypt usando certbot?

¿Tienes un sitio web y quieres ahorrarte unos cuantos dólares del costo de un certificado digital?

Estás de suerte, Let's Encrypt te ofrece certificados digitales gratuitos.

Estos certificados tienen una duración de 90 días y pueden ser renovados con cierta automatización.

Let's Encrypt recomienda usar clientes ACME para actualizar los certificados, el cliente oficial es Certbot

¿Y cuáles son los pasos para usar estos certificados?

Aquí pongo los pasos para usarlo en Ubuntu con Nginx:

- Instalar algunos paquetes
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-nginx

Luego, le pedimos a certbot que genere e instale un certificado en Nginx y vamos respondiendo las preguntas que certbot nos va haciendo
$ certbot --nginx

Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): mi.correo@real.com

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

-------------------------------------------------------------------------------
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 EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y

Which names would you like to activate HTTPS for?
-------------------------------------------------------------------------------
1: mi.dominio.com
2: mi.otrodominio.com
-------------------------------------------------------------------------------
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):1
Obtaining a new certificate
Performing the following challenges:
tls-sni-01 challenge for mi.dominio.com
Waiting for verification...
Cleaning up challenges
Deployed Certificate to VirtualHost /etc/nginx/sites-enabled/midominio for set(['mi.dominio.com'])

Please choose whether HTTPS access is required or optional.
-------------------------------------------------------------------------------
1: Easy - Allow both HTTP and HTTPS access to these sites
2: Secure - Make all requests redirect to secure HTTPS access
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/midominio

-------------------------------------------------------------------------------
Congratulations! You have successfully enabled https://mi.dominio.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mi.dominio.com
-------------------------------------------------------------------------------

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/mi.dominio.com/fullchain.pem. Your
   cert will expire on 2017-09-04. 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
 

Y no queda más que disfrutar del certificado