Let’s Encrypt é uma autoridade de certificação lançada em 12 de abril de 2016, que fornece gratuitamente certificados de criptografia TLS X.509 através de um processo automatizado, criado para eliminar a complexidade dos processos atuais de criação, validação, instalação e renovação de certificados para sites seguros.
A Let’s Encrypt é uma autoridade certificadora (AC) gratuita, automatizada e aberta que opera em prol do benefício público.
Gratuita: Qualquer pessoa que possui um nome de domínio pode usar a Let’s Encrypt para obter um certificado confiável com custo zero.
Este recurso serve para proteger a troca de informações entre o servidor de hospedagem e seus usuários, garantindo o sigilo da comunicação e melhorando a segurança do site.
Pre – Requisitos
Debian 10
agora vamos por a mão na massa
$ su -
$ apt update
$ apt upgrade
$ apt install letsencrypt python-certbot-apache
crie um domínio virtual nas configurações do apache, caso não saiba vou deixar um link de exemplo abaixo
OBS: lembre de configurar e apontar seu domínio para um servidor DNS.
Criamos o arquivo que vai representar o host blog. Vou utilizar como base o diretório /var/www/teste que vamos criar em seguida.
$ nano /etc/apache2/sites-available/cloud.conf
<virtualhost *:80>
ServerName teste.jbits.com.br
ServerAdmin contato@jbits.com.br
DocumentRoot /var/www/teste
<directory /var/www/teste/ >
Options FollowSymLinks
AllowOverride All
</directory>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/error_cloud.log
CustomLog ${APACHE_LOG_DIR}/access_cloud.log combined
</virtualhost>
Por segurança remova a assinatura do servidor, evitando os possíveis ataques.
$ sed -i 's/ServerTokens OS/ServerTokens Prod/' /etc/apache2/conf-available/security.conf
$ sed -i 's/ServerSignature On/ServerSignature Off/' /etc/apache2/conf-available/security.conf
Crie o diretório e uma uma index só para representar nosso “olá mundo”.
$ mkdir /var/www/teste/
$ echo '<h1>Hello world!</h1>' > /var/www/teste/index.html
Antes de gerar o certificado pare “teste.jbits.com.br” pare o serviço apache
$ /etc/init.d stop apache.service
$ letsencrypt --authenticator standalone --installer apache -d teste.jbits.com.br
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer apache Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): seu@email.com.br - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 Obtaining a new certificate Performing the following challenges: http-01 challenge for teste.jbits.com.br Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/teste-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/teste-le-ssl.conf Enabling available site: /etc/apache2/sites-available/teste-le-ssl.conf 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://teste.jbits.com.br You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=teste.jbits.com.br - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/teste.jbits.com.br/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/teste.jbits.com.br/privkey.pem Your cert will expire on 2019-10-24. 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 / Lets Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
acesse o navegador digitando o dominio teste.jbits.com.br
Para renovar automaticamente crie um script e adicione ao cron.
$ nano /etc/renova-cert.sh
#!/bin/bash
/usr/bin/systemctl stop apache2
/usr/bin/certbot -q renew
/usr/bin/systemctl start apache2
Dê permissão para executar
$ chmod +x /etc/renova-cert.sh
Adicione para o Cron para toda meia noite renovar
$ echo '00 00 * * * root /etc/renova-cert.sh' >> /etc/crontab
$ systemctl restart cron
agora você tem domínio com certificado valido e com renovação automática 😉