Gestione di certificati SSL per Apache con letsencrypt: Difference between revisions
Jump to navigation
Jump to search
Created page with "{{Stub}} <pre> openssl req -new -sha256 -key domain.key -subj "/CN=www.rvmgroup.it" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:www.r..." |
mNo edit summary |
||
| Line 1: | Line 1: | ||
* Vogliamo installare un certificato ssl con | |||
:CNAME= www.example.com | |||
:ALTN: webmail.example.com | |||
* Il sito è servito da un webserver apache, con webroot in | |||
:/var/www/example.com/www/html/ | |||
=Procedura con letsencrypt.sh= | |||
==Configurazioen di Apache== | |||
* Per verificare l'attendibilità della richiesta, il server di Letsencrypt cercherà di reperire il files di verifica all'url | |||
:http://www.example.com/.well-known/acme-challenge/ | |||
* Quindi bisogna creare questa risorsa sul server apache in HTTP non in https, dove dovranno essere posizionati ifiles di verifica creati da letsencrypt.sh | |||
* Definiamo quindi questa risorsa: | |||
sudoedit /etc/apache/conf.d/letsencrypt.conf | |||
<pre> | |||
<Directory "/etc/letsencrypt.sh/.well-known/acme-challenge/"> | |||
Options None | |||
AllowOverride None | |||
Require all granted | |||
Header add Content-Type text/plain | |||
</Directory> | |||
Alias /.well-known/acme-challenge/ /etc/letsencrypt.sh/.well-known/acme-challenge/ | |||
</pre> | |||
* You need to make sure that all (sub-)domains that you want to sign have access to this directory! That includes rewrites etc. | |||
* The acme validation is done only using plain http and will not honour redirects etc. | |||
==Installazione== | |||
* Creare uno user di sistema apposito | |||
sudo adduser --system --bad-name letsencrypt.sh | |||
* Creare le directories necessarie: | |||
sudo mkdir -p /etc/letsencrypt.sh/{hooks,cron,config,.well-known/acme-challenge/} | |||
sudo touch /etc/letsencrypt.sh/config/dummy.sh | |||
sudo chown -R letsencrypt.sh /etc/letsencrypt.sh | |||
* Installare l'eseguibile: | |||
cd /tmp | |||
git clone https://github.com/lukas2511/letsencrypt.sh.git | |||
sudo cp letsencrypt.sh/letsencrypt.sh /usr/local/bin/ | |||
* Riavviare apache e testare se la directory sia servita: | |||
sudo systemctl restart apache2.service | |||
wget -O - http://www.example.com/.well-known/acme-challenge/ | |||
==Configurazione== | |||
* Modificare la configurazione: | |||
sudoedit config.sh | |||
CONFIG_D=/etc/letsencrypt.sh/config | |||
BASEDIR=/etc/letsencrypt.sh | |||
CONTACT_EMAIL=admin@example.com | |||
* Creare il wrapper che sarà eseguito da cron pre rinnovare i certificati: | |||
sudoedit cron/letsencrypt.cron.sh | |||
<pre> | |||
#!/bin/bash | |||
cd /etc/letsencrypt.sh | |||
/usr/local/bin/letsencrypt.sh --cron | |||
</pre> | |||
* Renderlo eseguibile: | |||
sudo chmod +x cron/letsencrypt.cron.sh | |||
* Sistemare i diritti dei files creati: | |||
sudo chown -R letsencrypt.sh /etc/letsencrypt.sh | |||
* Creare il file contenente i certificati da richiedere | |||
cd /etc/letsencrypt.sh | |||
sudoedit domains.txt | |||
www.example.com example.com | |||
* Testarlo: | |||
sudo -u letsencrypt.sh /etc/letsencrypt.sh/cron/letsencrypt.cron.sh | |||
* Se tutto funziona, i certificati saranno in | |||
/etc/letsencrypt.sh/certs/www.example.com/ | |||
:privkey.pem è la private key | |||
:fullchain.pem è il certificato concatenato con le CA | |||
:cert.pem è il certificato standalone | |||
* Linkare i certificati nella posizione standard di | |||
* Creare il file di cron | |||
sudoedit /etc/cron.d/letsencrypt | |||
01 11 * * * letsencrypt.sh /etc/letsencrypt.sh/cron/letsencrypt.cron.sh > /dev/null | |||
==Configurazione del Virtualhost HTTPS== | |||
* TBD | |||
==Script di deploy dei certificati== | |||
* TBD | |||
==Riferimenti== | |||
*[https://wiki.freebsd.org/BernardSpil/LetsEncrypt BernardSpil/LetsEncrypt - FreeBSD Wiki] | |||
=Procedura con acme-tiny= | |||
{{Stub}} | {{Stub}} | ||
Revision as of 20:28, 25 February 2016
- Vogliamo installare un certificato ssl con
- CNAME= www.example.com
- ALTN: webmail.example.com
- Il sito è servito da un webserver apache, con webroot in
- /var/www/example.com/www/html/
Procedura con letsencrypt.sh
Configurazioen di Apache
- Per verificare l'attendibilità della richiesta, il server di Letsencrypt cercherà di reperire il files di verifica all'url
- Quindi bisogna creare questa risorsa sul server apache in HTTP non in https, dove dovranno essere posizionati ifiles di verifica creati da letsencrypt.sh
- Definiamo quindi questa risorsa:
sudoedit /etc/apache/conf.d/letsencrypt.conf
<Directory "/etc/letsencrypt.sh/.well-known/acme-challenge/"> Options None AllowOverride None Require all granted Header add Content-Type text/plain </Directory> Alias /.well-known/acme-challenge/ /etc/letsencrypt.sh/.well-known/acme-challenge/
- You need to make sure that all (sub-)domains that you want to sign have access to this directory! That includes rewrites etc.
- The acme validation is done only using plain http and will not honour redirects etc.
Installazione
- Creare uno user di sistema apposito
sudo adduser --system --bad-name letsencrypt.sh
- Creare le directories necessarie:
sudo mkdir -p /etc/letsencrypt.sh/{hooks,cron,config,.well-known/acme-challenge/}
sudo touch /etc/letsencrypt.sh/config/dummy.sh
sudo chown -R letsencrypt.sh /etc/letsencrypt.sh
- Installare l'eseguibile:
cd /tmp git clone https://github.com/lukas2511/letsencrypt.sh.git sudo cp letsencrypt.sh/letsencrypt.sh /usr/local/bin/
- Riavviare apache e testare se la directory sia servita:
sudo systemctl restart apache2.service wget -O - http://www.example.com/.well-known/acme-challenge/
Configurazione
- Modificare la configurazione:
sudoedit config.sh
CONFIG_D=/etc/letsencrypt.sh/config BASEDIR=/etc/letsencrypt.sh CONTACT_EMAIL=admin@example.com
- Creare il wrapper che sarà eseguito da cron pre rinnovare i certificati:
sudoedit cron/letsencrypt.cron.sh
#!/bin/bash cd /etc/letsencrypt.sh /usr/local/bin/letsencrypt.sh --cron
- Renderlo eseguibile:
sudo chmod +x cron/letsencrypt.cron.sh
- Sistemare i diritti dei files creati:
sudo chown -R letsencrypt.sh /etc/letsencrypt.sh
- Creare il file contenente i certificati da richiedere
cd /etc/letsencrypt.sh
sudoedit domains.txt
www.example.com example.com
- Testarlo:
sudo -u letsencrypt.sh /etc/letsencrypt.sh/cron/letsencrypt.cron.sh
- Se tutto funziona, i certificati saranno in
/etc/letsencrypt.sh/certs/www.example.com/
- privkey.pem è la private key
- fullchain.pem è il certificato concatenato con le CA
- cert.pem è il certificato standalone
- Linkare i certificati nella posizione standard di
- Creare il file di cron
sudoedit /etc/cron.d/letsencrypt
01 11 * * * letsencrypt.sh /etc/letsencrypt.sh/cron/letsencrypt.cron.sh > /dev/null
Configurazione del Virtualhost HTTPS
- TBD
Script di deploy dei certificati
- TBD
Riferimenti
Procedura con acme-tiny
| Attenzione questo articolo è ancora incompleto. Sentiti libero di contribuire cliccando sul tasto edit. |
openssl req -new -sha256 -key domain.key -subj "/CN=www.rvmgroup.it" -reqexts SAN -config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:www.rvmgroup.it,DNS:support.rvmgroup.it,DNS:smtp.rvmgroup.it,DNS:webmail.rvmgroup.it")) |sudo tee domain.csr openssl req -in domain.csr -text -noout sudo python /opt/acme-tiny/acme_tiny.py --account-key ./account.key --csr ./domain.csr --acme-dir /var/www/rvmgroup.it/www/html/.well-known/acme-challenge/ | sudo tee ./signed.crt openssl x509 -in signed.crt -text -noout wget -O - https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem | sudo tee intermediate.pem cat signed.crt intermediate.pem | sudo tee chained.pem