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 | ||
linux:ssl [09-01-2020 10:57] edmc73 |
linux:ssl [17-12-2023 10:35] (Version actuelle) edmc73 |
||
---|---|---|---|
Ligne 10: | Ligne 10: | ||
- | ===== Avec StartSSL ===== | ||
- | Aller sur ce site => http:// | ||
- | Vous devrez valider votre email et nom de domaine en cliquant sur **Validations Wizard** | + | ===== Avec Let's Encrypt ===== |
- | Toujours dans **Validations Wizard** vous devez faire vérifier votre nom de domaine en choisissant **Domain Name Validation** | + | **MAJ 2024** |
+ | En résumé sur une fresh debian 11 | ||
- | Un mail de vérification sera envoyé à l' | + | apt install certbot python3-certbot-apache |
+ | |||
+ | < | ||
+ | # certbot --apache -d edmc73.com | ||
+ | Saving debug log to / | ||
+ | Plugins selected: Authenticator apache, Installer apache | ||
+ | Enter email address | ||
+ | | ||
- | Ensuite, cliquez sur **Certificates Wizard**, choisissez **Web Server SSL/TLS Certificate** dans la liste et fournissez un mot de passe pour la clé privé. | + | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+ | Please read the Terms of Service at | ||
+ | https:// | ||
+ | agree in order to register with the ACME server. Do you agree? | ||
+ | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
+ | (Y)es/(N)o: Y | ||
- | Copier/coller la clé sur votre serveur. Suivez les indications. | + | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+ | Would you be willing, once your first certificate is successfully issued, 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: Y | ||
+ | Account registered. | ||
+ | Requesting a certificate for edmc73.com | ||
+ | Performing the following challenges: | ||
+ | http-01 challenge for edmc73.com | ||
+ | Enabled Apache rewrite module | ||
+ | Waiting for verification... | ||
+ | Cleaning up challenges | ||
+ | Created an SSL vhost at / | ||
+ | Enabled Apache socache_shmcb module | ||
+ | Enabled Apache ssl module | ||
+ | Deploying Certificate to VirtualHost / | ||
+ | Enabling available site: / | ||
+ | Enabled Apache rewrite module | ||
+ | Redirecting vhost in / | ||
- | openssl rsa -in ssl.key | + | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
- | + | Congratulations! You have successfully enabled https:// | |
- | Cliquez sur **Continue** et choisissez votre nom de domaine. | + | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+ | Subscribe to the EFF mailing list (email: toto@toto.com). | ||
- | A la fin vous devez avoir 4 fichiers | + | IMPORTANT NOTES: |
- | ca.pem ssl.crt | + | - Congratulations! Your certificate and chain have been saved at: |
+ | / | ||
+ | | ||
+ | / | ||
+ | Your certificate will expire on 2024-03-16. To obtain a new or | ||
+ | | ||
+ | | ||
+ | renew *all* of your certificates, | ||
+ | - If you like Certbot, please consider supporting our work by: | ||
- | Configurer ensuite apache dans ce style | + | |
- | < | + | Donating to EFF: https://eff.org/donate-le |
- | < | + | |
- | | + | |
- | ErrorLog | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | ||
- | | ||
- | | ||
- | | ||
- | "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \" | ||
- | </ | ||
</ | </ | ||
+ | On se retrouve donc avec un nouveau fichier de config dans apache tout configuré pour que ça fonctionne en https. | ||
+ | |||
+ | ------------------------- | ||
- | ===== 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 146: | Ligne 176: | ||
</ | </ | ||
+ | <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 259: | Ligne 297: | ||
- | <note warning> | + | ==== module apache ==== |
- | 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 | + | Dans le cas d'un site web en python ou autre animal du genre ou on doit utiliser un proxy et donc bref, ça devient chiant. |
- | git clone https:// | + | |
- | | + | |
- | Je me dit, chouette un script tout prêt à l' | + | |
- | ./ | + | |
- | Cette commande lance l' | + | Ce module va écrire |
- | 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 | + | |
- | + | ||
- | J'ai l' | + | |
- | + | ||
- | ./ | + | |
- | --server https:// | + | |
- | Ce qui nous sort toutes les commandes à taper en root sur le serveur web | ||
< | < | ||
- | Make sure your web server displays the following content at | + | certbot_apache._internal.http_01: |
- | http:// | + | |
- | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | + | certbot_apache._internal.http_01: |
- | Content-Type header MUST be set to text/plain. | + | RewriteEngine on |
+ | RewriteRule ^/\.well-known/ | ||
- | If you don't have HTTP server configured, you can run the following | + | certbot_apache._internal.http_01:writing a post config file with text: |
- | command on the target server (as root): | + | < |
+ | Require all granted | ||
+ | </ | ||
+ | < | ||
+ | Require all granted | ||
+ | </ | ||
- | mkdir -p / | + | certbot.reverter: |
- | cd /tmp/letsencrypt/ | + | |
- | 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, mais ça me parait encore trop lourd, je décide de tester la méthode **webroot** où l'on définit sur le serveur web où se trouve le site que l'on veut mettre en https et il gère le reste | ||
- | ./ | ||
- | --server https:// | ||
- | |||
- | et la magie opère | ||
- | < | ||
- | Updating letsencrypt and virtual environment dependencies....... | ||
- | Running with virtualenv: sudo / | ||
- | |||
- | IMPORTANT NOTES: | ||
- | - Congratulations! Your certificate and chain have been saved at | ||
- | / | ||
- | | ||
- | the future, simply run Let's Encrypt again. | ||
</ | </ | ||
- | Maintenant nous avons 4 fichiers prêt à l' | ||
- | < | ||
- | < | ||
- | SSLEngine on | ||
- | SSLProtocol all -SSLv2 | ||
- | SSLCipherSuite ALL: | ||
- | SSLCertificateFile | ||
- | SSLCertificateKeyFile | ||
- | SSLCertificateChainFile / | ||
- | SSLCACertificateFile | ||
- | SetEnvIf User-Agent “.*MSIE.*” nokeepalive ssl-unclean-shutdown | ||
- | </ | ||
- | </ | ||
- | On reload apache | ||
- | service apache2 reload | ||
- | |||
- | et voici le résultat | ||
- | {{: | ||
- | |||
- | Pour renouveler le certificat, il suffit de relancer la même dernière commande. | ||
- | |||
- | Le certificat est valide 90 jours, donc on peut lancer cette commande en automatique tous les 88 jours par exemple via le cron. | ||
- | |||
- | 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 letsencrypt pour renouveler le certificat. | ||
- | |||
- | N' | ||
- | <code bash> | ||
- | #!/bin/bash | ||
- | |||
- | if test `find / | ||
- | then | ||
- | / | ||
- | fi | ||
- | </ | ||
- | |||
- | Pour avoir un peu d'aide | ||
- | ./ | ||
- | |||
- | |||
- | ====== Retour d' | ||
- | Après 90 jours, c'est donc le moment fatidique de mettre à jour le certificat. Pour info nous recevons un mail de notification d' | ||
- | En lançant la commande | ||
- | / | ||
- | |||
- | J' | ||
- | 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: ' | ||
- | |||
- | |||
- | Je lance le script tout seul | ||
- | ./ | ||
- | 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: | ||
- | - Congratulations! Your certificate and chain have been saved at | ||
- | / | ||
- | | ||
- | the future, simply run Let's Encrypt again. | ||
- | - If you like Let's Encrypt, please consider supporting our work by: | ||
- | |||
- | | ||
- | | ||
- | </ | ||
- | |||
- | Par contre il faut quand même recharger apache | ||
- | service apache2 reload | ||
- | Sinon le nouveau certificat n'est pas disponible | ||
- | |||
- | ===== 2ème retour ===== | ||
- | |||
- | let's encrypt a changé de script. | ||
- | |||
- | Après avoir réinstallé leur nouveau script **certbot**, | ||
- | < | ||
- | # ./ | ||
- | Checking for new version... | ||
- | Requesting root privileges to run certbot... | ||
- | / | ||
- | |||
- | IMPORTANT NOTES: | ||
- | - Congratulations! Your certificate and chain have been saved at | ||
- | / | ||
- | | ||
- | the future, simply run Certbot again. | ||
- | - If you like Certbot, please consider supporting our work by: | ||
- | |||
- | | ||
- | | ||
- | |||
- | </ | ||
- | La première fois, un email vous sera demandé ainsi qu'une validation de la licence, des infos seront stocké dans / | ||
==== Commandes ==== | ==== Commandes ==== | ||
Ligne 444: | Ligne 346: | ||
Si vous changer le path dans votre config apache, vous pouvez modifier la config letsencrypt à la main dans **/ | Si vous changer le path dans votre config apache, vous pouvez modifier la config letsencrypt à la main dans **/ | ||
certbot renew --dry-run | certbot renew --dry-run | ||
+ | | ||
===== Avec certbot de debian ===== | ===== Avec certbot de debian ===== | ||
Ligne 489: | Ligne 392: | ||
certbot certonly --webroot -w / | certbot certonly --webroot -w / | ||
Ce sera le même répertoire pour tous les domaines de votre serveur. | 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 | ||
+ | |||
+ | <code apache> | ||
+ | ProxyPass / | ||
+ | ProxyPass / http:// | ||
+ | ProxyPassReverse / http:// | ||
+ | </ | ||
+ | |||
+ | |||
===== Alternative à certbot ===== | ===== Alternative à certbot ===== | ||
Ligne 545: | Ligne 458: | ||
</ | </ | ||
+ | |||
+ | ===== 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** | ||
+ | |||
+ | 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 \" | ||
+ | </ | ||
+ | </ |