strutture:lnf:dr:calcolo:sistemi:letsencrypt
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| strutture:lnf:dr:calcolo:sistemi:letsencrypt [2018/03/18 15:19] – dmaselli@infn.it | strutture:lnf:dr:calcolo:sistemi:letsencrypt [2018/03/20 10:03] (current) – dmaselli@infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Certificati SSL automatici per Server Web ====== | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | Creare certificato e relativa request per il sito web: | ||
| + | openssl genrsa 4096 > / | ||
| + | chown apache / | ||
| + | chmod 600 / | ||
| + | |||
| + | Creare la CSR con CN= a hostname: | ||
| + | openssl req -new -sha256 -key / | ||
| + | |||
| + | Impostare temporaneamente la CSR come CRT: | ||
| + | cp / | ||
| + | cp / | ||
| + | cp / | ||
| + | |||
| + | Creare la directory acme-challenge per il webserver: | ||
| + | mkdir / | ||
| + | |||
| + | Far puntare i file dei certificati e configurare Apache per esportare una directory acme-challenge in http in chiaro: | ||
| + | |||
| + | <code bash> | ||
| + | cat > / | ||
| + | SSLCACertificateFile / | ||
| + | SSLCertificateFile / | ||
| + | SSLCertificateKeyFile / | ||
| + | SSLCertificateChainFile / | ||
| + | |||
| + | # https:// | ||
| + | # intermediate configuration, | ||
| + | SSLProtocol | ||
| + | SSLCipherSuite | ||
| + | SSLHonorCipherOrder | ||
| + | SSLCompression | ||
| + | SSLSessionTickets | ||
| + | |||
| + | Alias / | ||
| + | < | ||
| + | < | ||
| + | # Apache 2.4 | ||
| + | | ||
| + | </ | ||
| + | < | ||
| + | # Apache 2.2 | ||
| + | Order allow,deny | ||
| + | Allow from All | ||
| + | </ | ||
| + | php_flag engine off | ||
| + | AllowOverride None | ||
| + | Options None | ||
| + | </ | ||
| + | EOT | ||
| + | </ | ||
| + | |||
| + | Far ripartire Apache: | ||
| + | service httpd restart | ||
| + | |||
| + | Creare un utente " | ||
| + | useradd acme | ||
| + | |||
| + | Autorizzare l' | ||
| + | echo 'acme ALL=NOPASSWD: | ||
| + | |||
| + | Sistemare permessi file: | ||
| + | chown acme / | ||
| + | chown acme / | ||
| + | chown acme / | ||
| + | chown acme / | ||
| + | | ||
| + | Da ora in poi come utente " | ||
| + | su - acme | ||
| + | |||
| + | Creare la chiave del richiedente per il protocollo ACME: | ||
| + | openssl genrsa 4096 > account.key | ||
| + | | ||
| + | Creare symlink ai file dei certificati: | ||
| + | ln -s / | ||
| + | ln -s / | ||
| + | ln -s / | ||
| + | ln -s / | ||
| + | ln -s / | ||
| + | | ||
| + | Per avere una csr con tutti gli host configurati su apache: | ||
| + | <code bash> | ||
| + | cat > get_certs_for_all_aliases.sh <<' | ||
| + | #!/bin/bash | ||
| + | |||
| + | aliases= | ||
| + | sep= | ||
| + | for host in `httpd -S | egrep ' | ||
| + | |||
| + | checkfile=checkme$RANDOM | ||
| + | echo " | ||
| + | |||
| + | RESP=`curl -s http:// | ||
| + | |||
| + | if [ " | ||
| + | echo $host is host alias | ||
| + | aliases=$aliases${sep}DNS: | ||
| + | sep=',' | ||
| + | # else | ||
| + | # echo $host is NOT host alias | ||
| + | fi | ||
| + | |||
| + | done | ||
| + | |||
| + | rm -f / | ||
| + | |||
| + | openssl req -text -new -sha256 -key / | ||
| + | EOT | ||
| + | |||
| + | chmod +x get_certs_for_all_aliases.sh | ||
| + | </ | ||
| + | |||
| + | Scaricare acme-tiny | ||
| + | git clone https:// | ||
| + | | ||
| + | |||
| + | Creare una directory tmp nella home di acme: | ||
| + | mkdir tmp | ||
| + | | ||
| + | Creare lo script di renew: | ||
| + | <code bash> | ||
| + | cat > renew.sh <<' | ||
| + | #!/bin/bash | ||
| + | |||
| + | cd $HOME | ||
| + | |||
| + | curl -s https:// | ||
| + | if [ $? != 0 ]; then | ||
| + | echo "Error downloading chain pem. Exiting." | ||
| + | exit 1 | ||
| + | fi | ||
| + | cat tmp/ | ||
| + | |||
| + | python acme-tiny/ | ||
| + | if [ $? != 0 ]; then | ||
| + | echo "Error requesting certificate. Exiting." | ||
| + | exit 1 | ||
| + | fi | ||
| + | cat tmp/$$.cert > https.crt && rm -f tmp/$$.cert | ||
| + | cat https-chain.crt >> https-chained.crt | ||
| + | |||
| + | sudo service httpd reload > /dev/null | ||
| + | if [ $? != 0 ]; then | ||
| + | echo "Error reloading httpd. Exiting." | ||
| + | exit 1 | ||
| + | fi | ||
| + | EOT | ||
| + | |||
| + | chmod +x renew.sh | ||
| + | </ | ||
| + | |||
| + | |||
| + | Eseguire il primo renew: | ||
| + | / | ||
| + | | ||
| + | Configurare il crontab, sempre come utente acme: | ||
| + | 30 9 15 * * / | ||
| + | |||
