Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
linux:ssl [15-05-2017 11:06] edmc73 [2ème retour] |
linux:ssl [24-06-2021 16:20] edmc73 |
||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
Ou comment avoir un **https** pour son site. | Ou comment avoir un **https** pour son site. | ||
+ | Cette page est à réorganiser car il y a eu beaucoup de test et certaines infos sont obsolètes. Voici quelques liens : | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
- | ===== Avec StartSSL ===== | ||
- | Aller sur ce site => http:// | ||
- | Vous devrez valider votre email et nom de domaine en cliquant sur **Validations Wizard** | ||
- | Toujours dans **Validations Wizard** vous devez faire vérifier votre nom de domaine en choisissant **Domain Name Validation** | + | ===== Avec Let's Encrypt ===== |
- | + | ||
- | Un mail de vérification sera envoyé à l'une (que vous choisissez) des adresses email renseigné pour votre nom de domaine. | + | |
- | + | ||
- | Ensuite, cliquez sur **Certificates Wizard**, choisissez **Web Server SSL/TLS Certificate** dans la liste et fournissez un mot de passe pour la clé privé. | + | |
- | + | ||
- | Copier/ | + | |
- | + | ||
- | openssl rsa -in ssl.key -out ssl.key | + | |
- | + | ||
- | Cliquez sur **Continue** et choisissez votre nom de domaine. | + | |
- | + | ||
- | A la fin vous devez avoir 4 fichiers | + | |
- | ca.pem | + | |
- | + | ||
- | Configurer ensuite apache dans ce style | + | |
- | < | + | |
- | < | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | + | |
- | </ | + | |
- | </ | + | |
- | ===== Avec Let's Encrypt ===== | ||
Let's Encrypt a bien évolué depuis sa version beta, je vais maintenant mettre mes scripts à jour et détailler le fonctionnement sur Debian 7 et Apache | Let's Encrypt a bien évolué depuis sa version beta, je vais maintenant mettre mes scripts à jour et détailler le fonctionnement sur Debian 7 et Apache | ||
Ligne 59: | Ligne 29: | ||
< | < | ||
# apt update | # apt update | ||
- | # apt install certbot | + | # apt install certbot |
+ | </ | ||
- | et la PAF !! | + | Pour émettre un certificat, letsencrypt doit s’assurer que vous avez bien la main sur les ressources à certifier. Letsencrypt propose 3 types de challenge : |
- | Les paquets supplémentaires suivants seront installés : | + | * HTTP-01 : challenge par requête http, le plus couramment utilisé pour les certificats simples |
- | dialog python-acme python-certbot python-cffi-backend python-configargparse python-configobj python-cryptography python-dialog python-dnspython python-enum34 python-funcsigs | + | |
- | python-idna python-ipaddress python-mock python-ndg-httpsclient python-openssl python-parsedatetime python-pbr python-pkg-resources python-psutil python-pyasn1 python-pyicu | + | |
- | python-requests python-rfc3339 python-setuptools python-six python-tz python-urllib3 python-zope.component python-zope.event python-zope.interface | + | |
- | Paquets suggérés : | + | |
- | | + | |
- | python-openssl-doc python-openssl-dbg python-psutil-doc doc-base python-socks python-setuptools-doc python-ntlm | + | |
- | Paquets recommandés : | + | |
- | letsencrypt | + | |
- | Les NOUVEAUX paquets suivants seront installés : | + | |
- | certbot dialog python-acme python-certbot python-cffi-backend python-configargparse python-configobj python-cryptography python-dialog python-dnspython python-enum34 python-funcsigs | + | |
- | python-idna python-ipaddress python-mock python-ndg-httpsclient python-openssl python-parsedatetime python-pbr python-psutil python-pyasn1 python-pyicu python-requests python-rfc3339 | + | |
- | python-setuptools python-tz python-urllib3 python-zope.component python-zope.event python-zope.interface | + | |
- | Les paquets suivants seront mis à jour : | + | |
- | | + | |
- | 2 mis à jour, 30 nouvellement installés, 0 à enlever et 101 non mis à jour. | + | |
- | Il est nécessaire de prendre 2 308 ko dans les archives. | + | |
- | Après cette opération, 11,8 Mo d' | + | |
- | </ | + | |
+ | Si dans le cas d’un site web, cette validation se résume généralement à vérifier que vous avez la main sur le serveur web, dans le cas d’un certificat wildcard il faut prouver que vous avez la main sur l’ensemble du domaine. Aussi, seul le challenge DNS-01 est possible pour des certificats wildcard letsencrypt, | ||
Je décide d' | Je décide d' | ||
Ligne 102: | Ligne 58: | ||
</ | </ | ||
+ | |||
+ | Dans le cas d'un wildcard avec authentification par DNS | ||
+ | |||
+ | < | ||
+ | # certbot certonly --manual -d ' | ||
+ | Saving debug log to / | ||
+ | Plugins selected: Authenticator manual, Installer None | ||
+ | Obtaining a new certificate | ||
+ | Performing the following challenges: | ||
+ | dns-01 challenge for edmc73.com | ||
+ | |||
+ | ------------------------------------------------------------------------------- | ||
+ | NOTE: The IP of this machine will be publicly logged as having requested this | ||
+ | certificate. If you're running certbot in manual mode on a machine that is not | ||
+ | your server, please ensure you're okay with that. | ||
+ | |||
+ | Are you OK with your IP being logged? | ||
+ | ------------------------------------------------------------------------------- | ||
+ | (Y)es/(N)o: y | ||
+ | |||
+ | ------------------------------------------------------------------------------- | ||
+ | Please deploy a DNS TXT record under the name | ||
+ | _acme-challenge.edmc73.com with the following value: | ||
+ | |||
+ | 6CmoURMbv3F14hJdzR8zqXrhcYJeKWJEhT8xZcz4gUY | ||
+ | |||
+ | Before continuing, verify the record is deployed. | ||
+ | ------------------------------------------------------------------------------- | ||
+ | Press Enter to Continue | ||
+ | </ | ||
+ | C'est à ce moment la que vous allez ajouter une entrée DNS sur votre nom de domaine. Ensuite pressez Enter :) | ||
+ | |||
+ | < | ||
+ | Waiting for verification... | ||
+ | Cleaning up challenges | ||
+ | |||
+ | IMPORTANT NOTES: | ||
+ | - Congratulations! Your certificate and chain have been saved at: | ||
+ | / | ||
+ | Your key file has been saved at: | ||
+ | / | ||
+ | Your cert will expire on 2033-06-13. To obtain a new or tweaked | ||
+ | | ||
+ | | ||
+ | | ||
+ | - If you like Certbot, please consider supporting our work by: | ||
+ | |||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | <note warning> | ||
+ | |||
+ | Vous devrez retaper la commande suivante pour renouveler le certificat à la main. | ||
+ | # certbot certonly --manual -d *.edmc73.com | ||
+ | |||
+ | Voir la doc: https:// | ||
+ | Et un tuto pour automatiser avec l'api ovh: https:// | ||
+ | </ | ||
Tous les fichiers sont dans **/ | Tous les fichiers sont dans **/ | ||
Ligne 119: | Ligne 134: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ou bien, variante fourni par letsencrypt | ||
+ | |||
+ | < | ||
+ | < | ||
+ | # Baseline setting to Include for SSL sites | ||
+ | |||
+ | SSLEngine on | ||
+ | | ||
+ | # Intermediate configuration, | ||
+ | SSLProtocol | ||
+ | SSLCipherSuite | ||
+ | SSLHonorCipherOrder | ||
+ | SSLCompression | ||
+ | |||
+ | SSLOptions +StrictRequire | ||
+ | |||
+ | # Add vhost name to log entries: | ||
+ | LogFormat "%h %l %u %t \" | ||
+ | LogFormat "%v %h %l %u %t \" | ||
+ | |||
+ | #CustomLog / | ||
+ | #LogLevel warn | ||
+ | #ErrorLog / | ||
+ | |||
+ | # Always ensure Cookies have " | ||
+ | #Header edit Set-Cookie (? | ||
+ | |||
+ | SSLCipherSuite ALL: | ||
+ | SSLCertificateFile | ||
+ | SSLCertificateKeyFile | ||
+ | SSLCertificateChainFile / | ||
+ | SSLCACertificateFile | ||
+ | SetEnvIf User-Agent “.*MSIE.*” nokeepalive ssl-unclean-shutdown | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
On reload apache | On reload apache | ||
Ligne 175: | Ligne 230: | ||
- | <note warning> | ||
- | Après avoir demandé une invitation pour tester en avant première ce nouveau service de certificat ssl gratuit, j'ai reçu un mail avec quelques commandes à taper. | ||
- | 1ère chose, récupérer le script | ||
- | git clone https:// | ||
- | If you're running Apache on a recent Debian-based OS, you can try the Apache plugin, which automates both obtaining and installing certs: | ||
- | Je me dit, chouette un script tout prêt à l' | ||
- | ./ | ||
- | Cette commande lance l' | ||
- | Tout ça pour lancer un script dans un environnement virtuel de python qui se résume par un échec. | ||
- | < | ||
- | Running with virtualenv: sudo / | ||
- | The apache plugin is not working; there may be problems with your existing configuration. | ||
- | The error was: PluginError(' | ||
- | </ | ||
- | Bien que tous les efforts ont été fait pour nous simplifier la vie, je n'aime pas vraiment ça, surtout pour installer un certificat ssl qui ne demande qu'à copier 3-4 fichiers et écrire quelques lignes de config dans apache. | ||
- | J'ai l' | + | ==== Commandes ==== |
+ | < | ||
+ | La commande qui va bien, pensez bien à associer le certificat pour le nom de domaine + le www. | ||
- | ./letsencrypt-auto certonly -a manual | + | |
- | | + | |
- | Ce qui nous sort toutes les commandes à taper en root sur le serveur web | + | Ne pas oublié un reload d' |
- | < | + | |
- | Make sure your web server displays the following content at | + | |
- | http:// | + | |
- | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | + | Pour voir la liste des certificats installés sur le système |
+ | ./ | ||
- | Content-Type header MUST be set to text/plain. | + | Ensuite pour supprimer un certificat du système |
+ | ./certbot-auto delete --cert-name p2pfr.com | ||
- | If you don't have HTTP server configured, you can run the following | + | Si vous changer le path dans votre config apache, vous pouvez modifier la config letsencrypt à la main dans **/ |
- | command on the target server (as root): | + | certbot renew --dry-run |
+ | |||
+ | ===== Avec certbot de debian ===== | ||
- | mkdir -p / | + | Maintenant certbot est directement intégré à debian 8 Jessie |
- | cd / | + | |
- | printf " | + | |
- | # run only once per server: | + | |
- | $(command -v python2 || command -v python2.7 || command -v python2.6) -c \ | + | |
- | " | + | |
- | SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map = {'': | + | |
- | s = BaseHTTPServer.HTTPServer(('', | + | |
- | s.serve_forever()" | + | |
- | </ | + | |
- | Alors ok, on voit mieux ce qui se passe, | + | La tache renew est maintenant un peu plus complexe car elle utilise systemd |
- | ./letsencrypt-auto certonly -a webroot --webroot-path | + | Bref, pour continuer de recevoir un mail à chaque renouvellement, |
- | --server https://acme-v01.api.letsencrypt.org/directory --agree-dev-preview | + | |
- | et la magie opère | + | < |
- | < | + | [Unit] |
- | Updating letsencrypt and virtual environment dependencies....... | + | Description=Certbot |
- | Running with virtualenv: sudo /home/user/.local/share/letsencrypt/bin/ | + | Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html |
- | + | Documentation=https://letsencrypt.readthedocs.io/ | |
- | IMPORTANT NOTES: | + | [Service] |
- | | + | Type=oneshot |
- | | + | ExecStartPre=/ |
- | | + | ExecStart=/usr/bin/certbot -q renew --no-self-upgrade |
- | the future, simply run Let' | + | PrivateTmp=true |
</ | </ | ||
- | Maintenant nous avons 4 fichiers prêt à l' | + | ===== Config apache |
- | < | + | |
- | < | + | |
- | SSLEngine on | + | |
- | SSLProtocol all -SSLv2 | + | |
- | SSLCipherSuite ALL: | + | |
- | SSLCertificateFile | + | |
- | SSLCertificateKeyFile | + | |
- | SSLCertificateChainFile / | + | |
- | SSLCACertificateFile | + | |
- | SetEnvIf User-Agent “.*MSIE.*” nokeepalive ssl-unclean-shutdown | + | |
- | </ | + | |
- | </ | + | |
- | On reload apache | + | En mode certonly, letsencrypt crée un répertoire à la racine de votre site web **.well-known/ |
- | service apache2 reload | + | |
- | et voici le résultat | + | Nous allons créer une config apache qui va centraliser toutes ces demandes dans un répertoire unique, par exemple **/ |
- | {{: | + | |
- | Pour renouveler | + | Créez |
+ | mkdir / | ||
- | Le certificat est valide 90 jours, donc on peut lancer cette commande en automatique tous les 88 jours par exemple via le cron. | + | Créez |
+ | <code apache> | ||
+ | Alias / | ||
+ | < | ||
+ | Options -Indexes | ||
+ | AllowOverride all | ||
+ | Require all granted | ||
+ | </ | ||
+ | </ | ||
- | Le cron ne permet pas d’exécuter un script tous les 88 jours, je propose donc un petit script que vous exécuterez tous les jours par le cron et qui fera un test sur la date du certificat pour savoir si il est plus vieux que 88 jours, et dans ce cas il exécutera le script | + | a2enconf |
+ | systemctl reload apache2 | ||
- | N' | + | et maintenant la commande certbot a utiliser |
- | <code bash> | + | certbot certonly |
- | #!/bin/bash | + | Ce sera le même répertoire pour tous les domaines de votre serveur. |
+ | |||
+ | Si vous utilisez un proxy pass, attention à exclure le chemin de letsencrypt comme ceci | ||
- | if test `find / | + | <code apache> |
- | then | + | ProxyPass |
- | /home/user/letsencrypt/ | + | |
- | fi | + | ProxyPassReverse |
</ | </ | ||
- | Pour avoir un peu d'aide | ||
- | ./ | ||
+ | ===== Alternative à certbot ===== | ||
- | ====== Retour d'expérience ====== | + | Si comme moi vous trouvez un peu relou l'installation |
- | Après 90 jours, c'est donc le moment fatidique | + | |
- | En lançant la commande | + | |
- | / | + | |
- | J' | + | https:// |
- | Updating letsencrypt and virtual environment dependencies...You are using pip version 7.1.2, however version 8.0.2 is available. | + | |
- | You should consider upgrading via the 'pip install --upgrade pip' command. | + | |
- | ..Could not open requirements file: [Errno 2] No such file or directory: ' | + | |
+ | An ACME protocol client written purely in Shell (Unix shell) language. | ||
+ | Full ACME protocol implementation. | ||
+ | Simple, powerful and very easy to use. You only need 3 minutes to learn it. | ||
+ | Bash, dash and sh compatible. | ||
+ | Simplest shell script for Let's Encrypt free certificate client. | ||
+ | Purely written in Shell with no dependencies on python or the official Let's Encrypt client. | ||
+ | Just one script to issue, renew and install your certificates automatically. | ||
+ | DOES NOT require root/sudoer access. | ||
+ | It's probably the easiest& | ||
- | Je lance le script tout seul | + | Pas encore encore testé, mais recommandé par proxmox ( https://pve.proxmox.com/wiki/HTTPS_Certificate_Configuration_(Version_4.x_and_newer)# |
- | ./letsencrypt-auto | + | |
- | Updating letsencrypt and virtual environment dependencies....... | + | |
- | Running with virtualenv: | + | |
- | No installers seem to be present and working on your system; fix that or try running letsencrypt with the " | + | |
- | Je lance avec le " | ||
- | < | ||
- | Updating letsencrypt and virtual environment dependencies....... | ||
- | Running with virtualenv: / | ||
- | Use of --agree-dev-preview is deprecated. | ||
- | IMPORTANT NOTES: | + | ===== Let' |
- | - Congratulations! Your certificate and chain have been saved at | + | |
- | / | + | |
- | | + | |
- | the future, simply run Let' | + | |
- | - If you like Let's Encrypt, please consider supporting our work by: | + | |
- | | + | en gros suivre ce guide officiel => https://certbot.eff.org/lets-encrypt/centosrhel7-nginx |
- | | + | |
- | </code> | + | |
- | Par contre il faut quand même recharger apache | + | yum install python2-certbot-nginx |
- | service apache2 reload | + | |
- | Sinon le nouveau certificat n'est pas disponible | + | |
- | ===== 2ème retour ===== | + | Pour ne pas toucher à ma conf nginx j'ai lancé la commande suivante |
+ | certbot --nginx certonly -d monnomdedomaine.fr | ||
+ | Cela permet d' | ||
- | let's encrypt a changé de script. | + | Les certificats se trouvent dans / |
- | Après avoir réinstallé leur nouveau script **certbot**, la nouvelle | + | Pour vérifier, lancez simplement |
- | < | + | certbot |
- | # ./certbot-auto certonly --webroot -w / | + | |
- | Checking for new version... | + | |
- | Requesting root privileges to run certbot... | + | |
- | / | + | |
- | IMPORTANT NOTES: | + | Exemple de conf nginx |
- | - Congratulations! Your certificate and chain have been saved at | + | <code nginx> |
- | / | + | server |
- | expire on 2016-08-11. To obtain a new version of the certificate in | + | listen 80; |
- | the future, simply run Certbot again. | + | server_name votrenomde.domaine; |
- | - If you like Certbot, please consider supporting our work by: | + | # pour forcer le site en https |
- | + | rewrite ^ https://$server_name$request_uri? | |
- | Donating to ISRG / Let's Encrypt: | + | } |
- | Donating to EFF: | + | |
+ | server { | ||
+ | | ||
+ | | ||
+ | ssl on; | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
</ | </ | ||
- | La première fois, un email vous sera demandé ainsi qu'une validation de la licence, des infos seront stocké dans / | ||
- | ==== Commandes | + | ===== Avec StartSSL ===== |
- | < | + | |
- | La commande qui va bien, pensez bien à associer le certificat pour le nom de domaine + le www. | + | |
- | # ./certbot-auto certonly --webroot -w /home/ | + | Aller sur ce site => http://www.startssl.com/ et créez-vous un compte. Il faudra ensuite installer le certificat qu'il vous fournirons pour vous identifier. |
- | Ne pas oublié un reload d' | + | Vous devrez valider votre email et nom de domaine |
- | service apache2 reload | + | |
- | Pour voir la liste des certificats installés sur le système | + | Toujours dans **Validations Wizard** vous devez faire vérifier votre nom de domaine en choisissant **Domain Name Validation** |
- | ./ | + | |
- | Ensuite | + | Un mail de vérification sera envoyé à l'une (que vous choisissez) des adresses email renseigné |
- | | + | |
+ | Ensuite, cliquez sur **Certificates Wizard**, choisissez **Web Server SSL/TLS Certificate** dans la liste et fournissez un mot de passe pour la clé privé. | ||
- | ===== Alternative à certbot ===== | + | Copier/ |
- | Si comme moi vous trouvez un peu relou l' | + | openssl rsa -in ssl.key -out ssl.key |
+ | |||
+ | Cliquez sur **Continue** et choisissez votre nom de domaine. | ||
- | https:// | + | A la fin vous devez avoir 4 fichiers |
+ | ca.pem ssl.crt ssl.key sub.class1.server.ca.pem | ||
- | An ACME protocol client written purely in Shell (Unix shell) language. | + | Configurer ensuite apache dans ce style |
- | Full ACME protocol implementation. | + | < |
- | | + | < |
- | Bash, dash and sh compatible. | + | DocumentRoot / |
- | | + | ErrorLog / |
- | | + | TransferLog / |
- | Just one script to issue, renew and install your certificates automatically. | + | |
- | DOES NOT require root/sudoer access. | + | SSLProtocol all -SSLv2 |
- | It's probably the easiest& | + | SSLCipherSuite ALL: |
- | Pas encore encore testé, mais recommandé par proxmox ( https://pve.proxmox.com/wiki/HTTPS_Certificate_Configuration_(Version_4.x_and_newer)# | + | |
+ | | ||
+ | | ||
+ | | ||
+ | "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | ||
+ | </ | ||
+ | </ |