Obtenir un certificat SSL Let’s Encrypt Wildcard

La version de production du server ACMEv2 de Let’s Encrypt est disponible depuis plusieurs semaines et il permet d’obtenir et d’installer des certificats SSL Wildcard pour sécuriser un domaine, ainsi que tous ses sous-domaine. Cela peut s’avérer particulièrement intéressant si vous héberger plusieurs sites sur des sous-domaines ou une instance WordPress Multi-sites.

Installer Acme.sh

Acme.sh s’installe facilement avec la commande suivante :

[pastacode lang= »markup » manual= »wget%20-O%20-%20%20https%3A%2F%2Fget.acme.sh%20%7C%20sh » message= » » highlight= » » provider= »manual »/]

Après l’installation, vous pouvez utiliser la commande  source ~/.bashrc ou fermer puis ré-ouvrir votre session pour activer l’auto-complétion.

Obtenir un certificat SSL Let’s Encrypt Wildcard

Validation DNS manuelle

Les certificats SSL Wildcards de Let’s Encrypt supportent uniquement la validation avec un enregistrement DNS, en mode manuel il est donc nécessaire de lancer acme.sh, puis de copier/coller l’enregistrement affiché et d’ajouter un enregistrement DNS.

Attention, le mode « validation DNS manuelle » ne supporte pas le renouvellement automatique du certificat, son utilisation n’est pas recommandée en production comme l’indique la documentation acme.sh

La commande pour générer un certificat SSL Wildcard avec Acme.sh en mode DNS manuel est la suivante :

[pastacode lang= »markup » manual= »acme.sh%20–issue%20-d%20votredomaine.tld%20-d%20*.votredomaine.tld%20–dns%20″ message= » » highlight= » » provider= »manual »/]

Mais s’agissant d’un mode de validation dont le renouvellement n’est pas automatique, il vous faudra ajouter l’argument --yes-I-know-dns-manual-mode-enough-go-ahead-please pour confirmer qu’il s’agit bien du mode de validation souhaité et que vous connaissez son fonctionnement.
Vous pouvez également définir d’autres options, comme le type de certificat ou la taille de la clé privée. Par exemple pour un certificat ECDSA avec un clé privée de 384 bits, la commande sera :

[pastacode lang= »markup » manual= »acme.sh%20–issue%20-d%20votredomaine.tld%20-d%20*.votredomaine.tld%20–dns%20–yes-I-know-dns-manual-mode-enough-go-ahead-please%20–keylength%20ec-384%20″ message= » » highlight= » » provider= »manual »/]

Acme.sh va générer la votre clé privée, ainsi que le CSR puis vous afficher les deux enregistrements DNS à ajouter :

[pastacode lang= »markup » manual= »root%40root%3A~%23%20acme.sh%20–issue%20-d%20votredomaine.tld%20-d%20*.votredomaine.tld%20–dns%20–keylength%20ec-384%20–yes-I-know-dns-manual-mode-enough-go-ahead-please%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A22%20(UTC%2B0100)%5D%20Domains%20have%20changed.%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A22%20(UTC%2B0100)%5D%20Multi%20domain%3D’DNS%3Avotredomaine.tld%2CDNS%3A*.votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A23%20(UTC%2B0100)%5D%20Getting%20domain%20auth%20token%20for%20each%20domain%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Getting%20webroot%20for%20domain%3D’votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Getting%20webroot%20for%20domain%3D’*.votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Add%20the%20following%20TXT%20record%3A%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Domain%3A%20’_acme-challenge.votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20TXT%20value%3A%20’TkcYtkbkvagdGG78YzLEdJF_JkV9GXtH8x-9f6nsM’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Please%20be%20aware%20that%20you%20prepend%20_acme-challenge.%20before%20your%20domain%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20so%20the%20resulting%20subdomain%20will%20be%3A%20_acme-challenge.votredomaine.tld%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Add%20the%20following%20TXT%20record%3A%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Domain%3A%20’_acme-challenge.votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20TXT%20value%3A%20’39boLncIG-2GWXx4GG8f6kgzDZAQrk_F7FwohnTE3Zo’%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Please%20be%20aware%20that%20you%20prepend%20_acme-challenge.%20before%20your%20domain%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20so%20the%20resulting%20subdomain%20will%20be%3A%20_acme-challenge.votredomaine.tld%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Please%20add%20the%20TXT%20records%20to%20the%20domains%2C%20and%20re-run%20with%20–renew.%0A%5Blundi%2019%20mars%202018%2C%2014%3A23%3A24%20(UTC%2B0100)%5D%20Please%20check%20log%20file%20for%20more%20details%3A%20%2Froot%2F.acme.sh%2Facme.sh.log » message= » » highlight= » » provider= »manual »/]

Ajoutez vous 2 enregistrements :

[pastacode lang= »markup » manual= »_acme-challenge.votredomaine.tld%20IN%20TXT%2039boLncIG-2GWXx4GG8f6kgzDZAQrk_F7FwohnTE3Zo%0A%0A_acme-challenge.votredomaine.tld%20IN%20TXT%20TkcYtkbkvagdGG78YzLEdJF_JkV9GXtH8x-9f6nsM » message= »Enregistrement TXT » highlight= » » provider= »manual »/]

Lors que vous aurez ajouté les deux enregistrements DNS sur votre domaine, vous pouvez lancer la phase de validation avec la commande :

[pastacode lang= »markup » manual= »acme.sh%20–renew%20-d%20votredomaine.tld%20–ecc%20–yes-I-know-dns-manual-mode-enough-go-ahead-please » message= » » highlight= » » provider= »manual »/]

L’option --ecc est nécessaire uniquement si vous avez généré une clé privée ECC.

Si le challenge ACME est validé, Acme.sh vous affichera l’emplacement dans lequel est stocké votre certificat SSL et votre clé privée :

[pastacode lang= »markup » manual= »root%40root%3A~%23%20acme.sh%20–renew%20–ecc%20-d%20votredomaine.tld%20–yes-I-know-dns-manual-mode-enough-go-ahead-please%0A%5Blundi%2019%20mars%202018%2C%2014%3A27%3A45%20(UTC%2B0100)%5D%20Renew%3A%20’votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A27%3A45%20(UTC%2B0100)%5D%20Skip%2C%20Next%20renewal%20time%20is%3A%20mardi%201%20mai%202018%2C%2011%3A54%3A03%20(UTC%2B0000)%0A%5Blundi%2019%20mars%202018%2C%2014%3A27%3A45%20(UTC%2B0100)%5D%20Add%20′–force’%20to%20force%20to%20renew.%0Aroot%40nginx%3A~%23%20acme.sh%20–renew%20–ecc%20-d%20votredomaine.tld%20–force%0A%5Blundi%2019%20mars%202018%2C%2014%3A27%3A59%20(UTC%2B0100)%5D%20Renew%3A%20’votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A00%20(UTC%2B0100)%5D%20Multi%20domain%3D’DNS%3Avotredomaine.tld%2CDNS%3A*.votredomaine.tld’%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A00%20(UTC%2B0100)%5D%20Getting%20domain%20auth%20token%20for%20each%20domain%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A00%20(UTC%2B0100)%5D%20Verifying%3Avotredomaine.tld%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A03%20(UTC%2B0100)%5D%20Success%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A03%20(UTC%2B0100)%5D%20Verifying%3A*.votredomaine.tld%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A06%20(UTC%2B0100)%5D%20Success%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A06%20(UTC%2B0100)%5D%20Verify%20finished%2C%20start%20to%20sign.%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A08%20(UTC%2B0100)%5D%20Cert%20success.%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A08%20(UTC%2B0100)%5D%20Your%20cert%20is%20in%20%20%2Froot%2F.acme.sh%2Fcerts%2Fvotredomaine.tld_ecc%2Fvotredomaine.tld.cer%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A08%20(UTC%2B0100)%5D%20Your%20cert%20key%20is%20in%20%20%2Froot%2F.acme.sh%2Fcerts%2Fvotredomaine.tld_ecc%2Fvotredomaine.tld.key%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A08%20(UTC%2B0100)%5D%20The%20intermediate%20CA%20cert%20is%20in%20%20%2Froot%2F.acme.sh%2Fcerts%2Fvotredomaine.tld_ecc%2Fca.cer%0A%5Blundi%2019%20mars%202018%2C%2014%3A28%3A08%20(UTC%2B0100)%5D%20And%20the%20full%20chain%20certs%20is%20there%3A%20%20%2Froot%2F.acme.sh%2Fcerts%2Fvotredomaine.tld_ecc%2Ffullchain.cer » message= » » highlight= » » provider= »manual »/]

Une fois terminé, vous pouvez mettre à jour votre fichier vhost comme d’habitude avec les clés fournis par ACME.

Sachez qu’il est possible de passer par les API des grands fournisseurs de domaine, tel que Cloudflare, DigitalOcean, OVH ou AWS Route 53. Voir leurs référenciels pour utiliser leurs API.

Sinon montez votre propre serveur DNS et scriptez pour l’ajout automatique des champs txt lors du renouvellement.

 

Sources

Laisser un commentaire