EL presente instructivo tiene como finalidad la instalación de certificados SSL LetsEncrypt a través de Certbot para un website bajo Apache2, todo esto en GNU/Linux Debian.
Requisitos:
- Se debe contar con suficiente privilegios para la configuración de aplicativos
- Se debe contar con instalación de Apache2
- Se debe contar con un dominio válido configurado “juantrucupei.com.ve”
Plataforma:
- Equipos de arquitectura 64 bits
- Sistema operativo ‘GNU/Linux’ Debian versión 9.0 (actualmente estable)
Aplicaciones:
- certbot 0.10.2-1
- python-certbot-apache 0.10.2-1
Nota:
Let’s Encrypt utiliza un mecanismo de chequeo de propiedad de dominio basado en la validación de un código númerico que se debe ubicar en un path específico del dominio en cuestión, mediante acceso web, que se genera al momento de solicitar el certificado. Es por ello que se requiere que tenga un dominio válido configurado, acceso al servidor donde se encuentra configurado ese dominio y un correo electrónico
Instalación de Paquetes:
root@server:/# aptitude install -y certbot python-certbot-apache
Configuración:
1. Generar un certificado para Apache2
root@server:/# certbot --authenticator standalone --installer apache -d juantrucupei.com.ve \ --pre-hook "service apache2 stop" --post-hook "service apache2 start"
Saving debug log to /var/log/letsencrypt/letsencrypt.log Running pre-hook command: service apache2 stop Obtaining a new certificate Performing the following challenges: http-01 challenge for juantrucupei.com.ve Waiting for verification... Cleaning up challenges Generating key (2048 bits): /etc/letsencrypt/keys/0000_key-certbot.pem Creating CSR: /etc/letsencrypt/csr/0000_csr-certbot.pem Running post-hook command: service apache2 start Created an SSL vhost at /etc/apache2/sites-available/000-default.conf_original-le-ssl.conf Deploying Certificate to VirtualHost /etc/apache2/sites-available/000-default.conf_original-le-ssl.conf Enabling available site: /etc/apache2/sites-available/000-default.conf_original-le-ssl.conf
2. Se presentan 02 opciones:
- 1: Fácil: permite tanto el acceso HTTP como HTTPS a estos sitios
- 2: Seguro: haga que todas las solicitudes se redireccionen para asegurar el acceso HTTPS
En éste caso se eligió la opción “2”
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): 2 Redirecting vhost in /etc/apache2/sites-available/000-default.conf_original to ssl vhost in /etc/apache2/sites-available/000-default.conf_original-le-ssl.conf ------------------------------------------------------------------------------- Congratulations! You have successfully enabled https://juantrucupei.com.ve You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=juantrucupei.com.ve ------------------------------------------------------------------------------- IMPORTANT NOTES: - ¡Felicidades! Su certificado y cadena se han guardado en /etc/letsencrypt/live/juantrucupei.com.ve/fullchain.pem. Tu cert expirará en 2018-12-16. Para obtener una versión nueva o retocada de este certificado en el futuro, simplemente ejecute certbot nuevamente con la opción "certonly". Para renovar no interactivamente *todos* tus certificados, ejecute "certbot renew" - 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
3. Verificar la presencia de los certificados:
root@server:/# ls -la /etc/letsencrypt/live/juantrucupei.com.ve/ total 12 drwxr-xr-x 2 root root 4096 sep 17 16:47 . drwx------ 3 root root 4096 sep 17 16:47 .. lrwxrwxrwx 1 root root 46 sep 17 16:47 cert.pem -> ../../archive/juantrucupei.com.ve/cert1.pem lrwxrwxrwx 1 root root 47 sep 17 16:47 chain.pem -> ../../archive/juantrucupei.com.ve/chain1.pem lrwxrwxrwx 1 root root 51 sep 17 16:47 fullchain.pem -> ../../archive/juantrucupei.com.ve/fullchain1.pem lrwxrwxrwx 1 root root 49 sep 17 16:47 privkey.pem -> ../../archive/juantrucupei.com.ve/privkey1.pem -rw-r--r-- 1 root root 543 sep 17 16:47 README
4. Verificar configuración Apache2
root@server:/# apache2ctl configtest
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message Syntax OK
Nota:
- Activar el módulo SSL de apache (# a2enmod ssl)
- Si se desea redirigir el tráfico de un host virtual previamente configurado por el puerto 80, se puede efectuar con un “Redirect permanent / https://juantrucupei.com.ve/”
RENOVAR CERTIFICADOS
1. Verificar la caducidad del certificado
root@server:/# openssl x509 -noout -dates -in /etc/letsencrypt/live/juantrucupei.com.ve/cert.pem
notBefore=Jun 11 18:37:45 2018 GMT notAfter=Sep 9 18:37:45 2018 GMT
2. Renovar certificado
root@server:/# certbot renew --post-hook "service apache2 restart"
3. Consultar certificados:
root@server:/# ls /etc/letsencrypt/live/juantrucupei.com.ve/
certbot ha creado 4 archivos:
- cert.pem: el certificado de los dominios.
- chain.pem: el certificado de la cadena de Let’s Encrypt.
- fullchain.pem: los dos certificados anteriores combinados.
- privkey.pem: la clave privada del certificado.
Pero en realidad son enlaces simbólicos a 4 archivos existentes en el directorio /etc/letsencrypt/archive/juantrucupei.com.ve/
- cert.pem -> ../../archive/juantrucupei.com.ve/cert1.pem
- chain.pem -> ../../archive/juantrucupei.com.ve/chain1.pem
- fullchain.pem -> ../../archive/juantrucupei.com.ve/fullchain1.pem
- privkey.pem -> ../../archive/juantrucupei.com.ve/privkey1.pem
Los nombres de los 4 archivos termina en un número, cada vez que renueve el certificado (tienen una duración de 3 meses) se crearán 4 archivos nuevos, con este número incrementado en una unidad, y los 4 enlaces simbólicos apuntarán a estos nuevos archivos.
Enlaces:
Let’s Encrypt
Instalar SSL con Lets Encrypt en Ubuntu con Apache
Cómo: Redirigir HTTP a HTTPS en Apache
Instalar un certificado SSL de Let’s Encrypt en Debian 8 (Jessie) con Apache 2.4
Implementación de Certificados Gratuitos Let’s Encrypt en Cisco ASA para Accesos VPN