nethserver_101_cahier_04_local_certificat_let_encrypt
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
nethserver_101_cahier_04_local_certificat_let_encrypt [2019-08-05 01:03] – michelandre | nethserver_101_cahier_04_local_certificat_let_encrypt [2025-01-12 19:30] (Version actuelle) – modification externe 127.0.0.1 | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | \\ | ||
+ | [[cours_nethserver_101|{{ Images_Cahier-101-04-000.png? | ||
+ | \\ | ||
+ | ====== Description générale ====== | ||
+ | ===== Introduction ===== | ||
+ | |||
+ | Le **Cahier-04** du cours **NethServer-101** décrit la marche à suivre pour installer gratuitement, | ||
+ | |||
+ | Un certificat émis par l' | ||
+ | |||
+ | ===== But final de ce Cahier ===== | ||
+ | |||
+ | {{Images_Cahier-101-03-005.png? | ||
+ | |||
+ | ==== Serveur virtuel ==== | ||
+ | |||
+ | {{ Images_Cahier-101-04-001.png? | ||
+ | \\ | ||
+ | |||
+ | === Serveur physique === | ||
+ | |||
+ | {{ Images_Cahier-101-04-002.png? | ||
+ | \\ | ||
+ | |||
+ | ===== Cours NethServer-101 ===== | ||
+ | |||
+ | Le //Cours NethServer-101//, | ||
+ | |||
+ | - [[nethserver_101_cahier_01_linux|Cahier-01]]: | ||
+ | - [[nethserver_101_cahier_02_installations_configurations_logiciels_prerequis|Cahier-02]]: | ||
+ | - [[nethserver_101_cahier_03_creation_un_serveur_virtuel|Cahier-03]]: | ||
+ | - [[nethserver_101_cahier_04_local_certificat_let_encrypt|Cahier-04]]: | ||
+ | - [[nethserver_101_cahier_05_vdsl_fqdn_internet_et_nethserver|Cahier-05]]: | ||
+ | // | ||
+ | - [[nethserver_101_cahier_06_nethserver_wordPress|Cahier-06]]: | ||
+ | - [[nethserver_101_cahier_07_nethserver_wordPress_wordfence|Cahier-07]]: | ||
+ | - [[nethserver_101_cahier_08_woocommerce_paypal_stripe|Cahier-08]]: | ||
+ | - [[nethserver_101_cahier_09_duplicator_migration|Cahier-09]]: | ||
+ | - [[nethserver_101_cahier_10_mandataire_inverse|Cahier-10]]: | ||
+ | - [[nethserver_101_cahier_11_nethserver_backuppc|Cahier-11]]: | ||
+ | |||
+ | ==== Cours NethServer-201 ==== | ||
+ | |||
+ | Le //Cours NethServer-201// | ||
+ | |||
+ | - [[nethserver_201_cahier_01_nethserver_et_dolibarr|Cahier-201-01]]: | ||
+ | - [[nethserver_201_cahier_02_odoo_12|Cahier-201-02]]: | ||
+ | - [[nethserver_201_cahier_03_mediawiki|Cahier-201-03]]: | ||
+ | - [[nethserver_201_cahier_04_dokuwiki|Cahier-201-04]]: | ||
+ | - [[nethserver_201_cahier_05_moodle|Cahier-201-05]]: | ||
+ | - [[nethserver_201_cahier_06_proxmox|Cahier-201-06]]: | ||
+ | - [[nethserver_201_cahier_07_flectra|Cahier-201-07]]: | ||
+ | |||
+ | ==== Logiciels ==== | ||
+ | |||
+ | Tous les logiciels nécessaires sont du domaine public ou LIBRE sous licence //GPL//; ils ne coûtent pas un sou. Le seul achat nécessaire est l' | ||
+ | |||
+ | ==== But final ==== | ||
+ | |||
+ | Après avoir suivi le //Cours NethServer-101//, | ||
+ | |||
+ | {{ NS-101_001_Diagramme.png? | ||
+ | |||
+ | ===== Particularités de ce document ===== | ||
+ | |||
+ | ==== Notes au lecteur ==== | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | ==== Conventions ==== | ||
+ | |||
+ | {{Images_icone-201-001_doigt.png? | ||
+ | {{Images_icone-201-002_Lumiere.png? | ||
+ | {{Images_icone-201-003_Note.png? | ||
+ | {{Images_icone-201-004_Triangle.png? | ||
+ | {{Images_icone-201-005_Non-termine.png? | ||
+ | {{Images_icone-201-006_Securite.png? | ||
+ | |||
+ | Toutes les commandes à la console ou à travers //PuTTY// sont précédées d'une invite qui est toujours présente. | ||
+ | |||
+ | < | ||
+ | [root@dorgee ~]# ping 10.10.10.75 -c1 | ||
+ | |||
+ | PING 10.10.10.75 (10.10.10.75) 56(84) bytes of data. | ||
+ | 64 bytes from 10.10.10.75: | ||
+ | |||
+ | --- 10.10.10.75 ping statistics --- | ||
+ | 1 packets transmitted, | ||
+ | rtt min/ | ||
+ | [root@dorgee ~]# | ||
+ | </ | ||
+ | |||
+ | <WRAP box round> | ||
+ | < | ||
+ | Commande à exécuter si ce n'est déjà fait. | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP box> | ||
+ | < | ||
+ | Commande indiquée à titre d' | ||
+ | </ | ||
+ | </ | ||
+ | \\ | ||
+ | |||
+ | ====== Glossaire ====== | ||
+ | |||
+ | Ce chapitre rassemble quelques termes pour permettre une brève introduction à la cryptographie. | ||
+ | |||
+ | **Cryptographie asymétrique** | ||
+ | |||
+ | // | ||
+ | La cryptographie asymétrique, | ||
+ | |||
+ | **Chiffrement** | ||
+ | |||
+ | <WRAP indent> | ||
+ | L'un des rôles de la clé publique est de permettre le chiffrement; | ||
+ | |||
+ | // | ||
+ | |||
+ | // | ||
+ | Le chiffrement est un procédé de cryptographie grâce auquel on souhaite rendre la compréhension d’un document impossible à toute personne qui n’a pas la clé de // | ||
+ | |||
+ | // | ||
+ | |||
+ | L’action de procéder à un chiffrement | ||
+ | // | ||
+ | **Déchiffrer**// | ||
+ | |||
+ | En informatique et en télécommunications, | ||
+ | |||
+ | // | ||
+ | |||
+ | Décrypter consiste à retrouver le texte original à partir d’un message chiffré sans posséder la clé de // | ||
+ | |||
+ | // | ||
+ | |||
+ | Le terme " | ||
+ | </ | ||
+ | |||
+ | **Échange de clésDiffie-Hellman** | ||
+ | |||
+ | // | ||
+ | En cryptographie, | ||
+ | |||
+ | **Somme de contrôle** | ||
+ | |||
+ | // | ||
+ | La somme de contrôle // | ||
+ | |||
+ | **Nonce** | ||
+ | |||
+ | // | ||
+ | Le nonce est un nombre arbitraire, à usage unique, utilisé pour signer un ensemble de données d'une communication électronique. Il permet notamment d' | ||
+ | |||
+ | **Condensat** | ||
+ | |||
+ | // | ||
+ | Séquence de caractères alphanumériques de longueur fixe qui représente le contenu d'un message, sans le révéler, dont la valeur unique est produite par un algorithme de hachage et qu'on utilise pour créer une signature numérique. | ||
+ | |||
+ | **Empreinte numérique** | ||
+ | |||
+ | // | ||
+ | L' | ||
+ | |||
+ | Une empreinte numérique a toujours la même taille, quelle que soit la longueur du message initial. À l' | ||
+ | |||
+ | **Homme-du-milieu** | ||
+ | |||
+ | // | ||
+ | {{ Images_Cahier-101-04-004.png? | ||
+ | |||
+ | **Certificat** | ||
+ | |||
+ | <WRAP indent> | ||
+ | // | ||
+ | Un certificat électronique //(aussi appelé certificat numérique ou certificat de clé publique)// peut être vu comme une carte d' | ||
+ | |||
+ | // | ||
+ | Dans le système X.509, une autorité de certification attribue un certificat liant une clé publique à un nom distinctif // | ||
+ | |||
+ | Ce certificat place la signature d'une autorité de certification dans le dernier champ. Concrètement, | ||
+ | |||
+ | //**Chaîne de certification**// | ||
+ | |||
+ | Le certificat de l' | ||
+ | |||
+ | // | ||
+ | |||
+ | Les certificats racines sont des clés publiques non signées, ou auto-signées, | ||
+ | </ | ||
+ | |||
+ | **Certificats à Validation de Domaine //(DV)//** | ||
+ | |||
+ | <WRAP indent> | ||
+ | // | ||
+ | Les certificats à Nom de Domaine //(DV)// sont émis très rapidement, et ce, en quelques minutes. Le propriétaire ou le webmestre du nom de domaine doit confirmer la requête par courriel. | ||
+ | |||
+ | Pendant votre demande, vous devez indiquer une adresse courriel pour confirmation; | ||
+ | |||
+ | // | ||
+ | |||
+ | Un certificat //SSL DV// est facile à obtenir. Vous obtenez ce certificat en quelques minutes. | ||
+ | |||
+ | //**Bon à savoir**// | ||
+ | |||
+ | Ce type de // | ||
+ | |||
+ | //**Pour qui?**// | ||
+ | |||
+ | Les certificats //DV// seront utilisés pour les sites Internet qui ont juste besoin d'une connexion https // | ||
+ | </ | ||
+ | |||
+ | **SAN et Wildcard** | ||
+ | |||
+ | <WRAP indent> | ||
+ | // | ||
+ | // | ||
+ | Que signifient les termes SAN //(Subject Alternative Names)// et UC //(Unified Communications)//? | ||
+ | |||
+ | Les certificats qui utilisent les SAN //(Subject Alternative Names)// sont des outils puissants qui permettent de sécuriser plusieurs noms de domaines de façon efficace et économique. Les certificats SSL Thawte permettent de sécuriser jusqu' | ||
+ | |||
+ | // | ||
+ | |||
+ | Au lieu d' | ||
+ | |||
+ | Par exemple, un seul certificat avec prise en charge des SAN serait capable de sécuriser les noms de domaines suivants: | ||
+ | |||
+ | - www.macompagnie.com | ||
+ | - mail.macompagnie.com | ||
+ | - macompagnie.com | ||
+ | - www.toto.net | ||
+ | - mail.toto.net | ||
+ | - toto.net | ||
+ | |||
+ | // | ||
+ | |||
+ | Les certificats Wildcard sont similaires aux certificats SAN avec quelques restrictions. Avec un certificat Wildcard, vous pouvez sécuriser plusieurs sous-domaines avec un seul domaine racine. Par exemple, si vous avez un certificat Wildcard pour www.macompagnie.com, | ||
+ | |||
+ | Cependant, vous ne pourrez pas sécuriser plusieurs domaines uniques comme // | ||
+ | |||
+ | // | ||
+ | |||
+ | Sécurisation de plusieurs sous-domaines sur un seul serveur. | ||
+ | |||
+ | Les certificats SSL Wildcard Thawte sécurisent plusieurs sous-domaines avec un certificat SSL unique, réduisant ainsi le temps et le coût de gestion. L' | ||
+ | </ | ||
+ | |||
+ | **CNAME** | ||
+ | |||
+ | <WRAP indent> | ||
+ | // | ||
+ | Un enregistrement CNAME ou enregistrement de //Nom Canonique// est un type d' | ||
+ | |||
+ | // | ||
+ | |||
+ | En utilisant les CNAME, vous rendez les données de votre DNS plus facile à gérer. Les enregistrements CNAME redirigent vers un // | ||
+ | |||
+ | L' | ||
+ | |||
+ | // | ||
+ | |||
+ | <WRAP column 55%> | ||
+ | Vous avez un site Web avec le nom de domaine // | ||
+ | |||
+ | Vous avez aussi plusieurs sous-domaines, | ||
+ | </ | ||
+ | <WRAP column 35%> | ||
+ | |{{ Images_Cahier-101-04-005.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | |||
+ | {{Images_Cahier-101-03-004.png? | ||
+ | </ | ||
+ | |||
+ | ====== Let's Encrypt ====== | ||
+ | |||
+ | ===== Principe de fonctionnement de Letsencrypt ===== | ||
+ | |||
+ | Référence: | ||
+ | Dans ce document, la facilité d' | ||
+ | |||
+ | Le script '' | ||
+ | |||
+ | - obtenir un certificat pour le//(s)// domaine// | ||
+ | - installer le certificat obtenu. | ||
+ | |||
+ | Pour obtenir un certificat, le script '' | ||
+ | |||
+ | - génère une paire de clés et une demande de signature de certificat // | ||
+ | - envoie la demande à un serveur ACME;\\ le serveur de noms // | ||
+ | - reçoit le certificat signé en retour. | ||
+ | |||
+ | Le script '' | ||
+ | |||
+ | Lancé à intervalle régulier, il répétera automatiquement la procédure s'il détecte qu'un certificat est sur le point d' | ||
+ | |||
+ | En définitive, | ||
+ | |||
+ | ===== Courriels du certificat ===== | ||
+ | |||
+ | Aucun courriel n'est envoyé pour confirmer le certificat, mais vous devez fournir une adresse courriel et un/des CNAME valides lors de l' | ||
+ | |||
+ | ===== Transparence des certificats ===== | ||
+ | |||
+ | Une partie de la mission de transparence de la société Let's Encrypt comprend la divulgation publique des certificats qu' | ||
+ | |||
+ | ===== Limites ===== | ||
+ | |||
+ | //**90 jours**// | ||
+ | |||
+ | Les certificats Let's Encrypt sont valides pour 90 jours. Let's Encrypt recommande de les renouveler tous les 60 jours pour avoir une certaine marge de manoeuvre. | ||
+ | |||
+ | //**5/7**// | ||
+ | |||
+ | // | ||
+ | < | ||
+ | < | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | |||
+ | < | ||
+ | |||
+ | ===== Mode Officiel vs TEST ===== | ||
+ | |||
+ | Si vous voulez tester le script '' | ||
+ | | ||
+ | |||
+ | Le principal avantage est de pouvoir demander autant de certificats que vous avez besoin pour vos tests sans vous heurter à la limite 5/7. | ||
+ | |||
+ | ==== Autorité de certification (CA) ==== | ||
+ | |||
+ | <WRAP indent> | ||
+ | == CA officielle == | ||
+ | |||
+ | Lors d'une demande de certificat officiel, le script '' | ||
+ | |||
+ | === CA de TEST === | ||
+ | |||
+ | Un certificat de test ne sera pas signé directement par Let's Encrypt mais par sa CA de tests, //Fake LE Intermediate X1//. Ce certificat de test ne sera pas reconnu par la plupart des navigateurs et affichera une erreur. La communication sera tout de même chiffrée. | ||
+ | |||
+ | La CA // | ||
+ | |||
+ | {{Images_Cahier-101-03-003.png? | ||
+ | </ | ||
+ | |||
+ | ===== Conditions préalables ===== | ||
+ | |||
+ | Le script '' | ||
+ | |||
+ | Il existe quelques configurations préalables à une demande de certificat. Par exemple, si nous essayons d' | ||
+ | |||
+ | - // | ||
+ | - Le résultat d'une recherche DNS de // | ||
+ | - Le Serveur NethServer est connecté directement à l' | ||
+ | - Les ports 80 et 443 sur le Serveur NethServer sont ouverts vers l' | ||
+ | |||
+ | Le script '' | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | ====== Certificat pour un domaine LOCAL ====== | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | // | ||
+ | Obtention d'un certificat de confiance Let's Encrypt pour un Serveur NethServer LOCAL accessible ou non depuis l' | ||
+ | |||
+ | ===== Serveur directement branché à l' | ||
+ | |||
+ | Pour l' | ||
+ | |||
+ | ===== Prérequis ===== | ||
+ | |||
+ | La prise en charge intégrée des certificats Let’s Encrypt nécessite que votre serveur soit accessible publiquement sur le <wrap em>port 80</ | ||
+ | |||
+ | ==== Contexte ==== | ||
+ | |||
+ | Nethserver 7 inclut la possibilité d’obtenir et de renouveler automatiquement un certificat TLS approuvé auprès de Let’s Encrypt. Cette fonctionnalité est fort utile, mais en raison de la méthode utilisée pour valider votre contrôle sur votre nom de domaine, elle ne convient pas aux serveurs sur un réseau LOCAL qui ne peuvent pas être atteints depuis l' | ||
+ | |||
+ | La prise en charge intégrée de Let’s Encrypt repose sur le mécanisme de validation **HTTP-01**. Pour le bon fonctionnement de ce dernier, les serveurs Let’s Encrypt doivent pouvoir se connecter à http:// | ||
+ | |||
+ | Le mécanisme de validation alternatif est le validateur DNS-01. Avec cette méthode, un enregistrement //DNS TXT// est créé pour //< | ||
+ | |||
+ | ==== La solution ==== | ||
+ | |||
+ | Nous allons décrire l' | ||
+ | |||
+ | Le site // | ||
+ | |||
+ | Toutes les commandes ci-dessous seront exécutées en tant que root à partir du shell sur votre Serveur NethServer. | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | Si votre fournisseur DNS ne dispose pas d'une API prise en charge, vous pouvez envisager d' | ||
+ | |||
+ | ===== Ouverture d'un compte chez Cloudflare ===== | ||
+ | |||
+ | // | ||
+ | // | ||
+ | |||
+ | Depuis début 2018, // | ||
+ | |||
+ | Cloudflare fournit des services DNS à 6 millions de sites Web, notamment: Uber, OKCupid et Fitbit. | ||
+ | |||
+ | {{ Images_Cahier-101-04-006.png? | ||
+ | ==== Connexion ==== | ||
+ | |||
+ | On se rend à l'URL [[https:// | ||
+ | <WRAP clear></ | ||
+ | |||
+ | ==== Configuration ==== | ||
+ | |||
+ | <WRAP column 30%> | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-007.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-008.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | Dans le courriel reçu, on clique **Verify email**. | ||
+ | |{{ Images_Cahier-101-04-009.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | Continue to the dashboard. | ||
+ | |{{ Images_Cahier-101-04-010.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | Si notre FQDN n'est pas là, on l' | ||
+ | |{{ Images_Cahier-101-04-011.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | **Setup**. | ||
+ | |{{ Images_Cahier-101-04-012.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | **Next**. | ||
+ | |{{ Images_Cahier-101-04-013.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-014.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | __Si on accepte__ les //Termes d' | ||
+ | |{{ Images_Cahier-101-04-015.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 30%> | ||
+ | // | ||
+ | |{{ Images_Cahier-101-04-016.png? | ||
+ | </ | ||
+ | <WRAP column 60%> | ||
+ | \\ | ||
+ | \\ | ||
+ | On insère les enregistrement CNAME que // | ||
+ | |{{ Images_Cahier-101-04-018.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-019.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-020.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP center> | ||
+ | <WRAP column 45%> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-022.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-023.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-026.png? | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | \\ | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-024.png? | ||
+ | |||
+ | **Continue**. | ||
+ | |{{ Images_Cahier-101-04-025-A.png? | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | ===== Serveurs de noms ===== | ||
+ | |||
+ | // | ||
+ | |||
+ | // | ||
+ | **ns1052.ui-dns.de**\\ | ||
+ | **ns1085.ui-dns.com** | ||
+ | |||
+ | // | ||
+ | < | ||
+ | < | ||
+ | |||
+ | Il nous indique aussi de supprimer, chez notre régistraire, | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | |{{ Images_Cahier-101-04-027.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | ==== Remplacement des serveurs de noms chez le régistraire de notre domaine ==== | ||
+ | |||
+ | Le régistraire pour notre domaine // | ||
+ | |||
+ | {{Images_Cahier-101-03-005.png? | ||
+ | |||
+ | <WRAP center> | ||
+ | <WRAP column 45%> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-028.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-029.png? | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | \\ | ||
+ | < | ||
+ | < | ||
+ | **Utiliser des serveurs de noms personnalisés**. | ||
+ | |{{ Images_Cahier-101-04-030.png? | ||
+ | |||
+ | |{{ Images_Cahier-101-04-031.png? | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | Dans l' | ||
+ | |||
+ | **elinore.ns.cloudflare.com**\\ | ||
+ | **joel.ns.cloudflare.com** | ||
+ | |||
+ | **Enregistrer**. | ||
+ | |||
+ | Ce remplacement des serveurs de noms supprimera tous ceux utilisés par // | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | |{{ Images_Cahier-101-04-032.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | |||
+ | L' | ||
+ | |||
+ | {{ Images_Cahier-101-04-033.png? | ||
+ | \\ | ||
+ | |||
+ | ===== Retour chez Cloudflare ===== | ||
+ | |||
+ | <WRAP center> | ||
+ | <WRAP column 45%> | ||
+ | **Continue**. | ||
+ | |{{ Images_Cahier-101-04-034.png? | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | Tout s'est bien déroulé. | ||
+ | |{{ Images_Cahier-101-04-035.png? | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | **Overview**. | ||
+ | |||
+ | {{ Images_Cahier-101-04-036.png? | ||
+ | \\ | ||
+ | |||
+ | ===== Clé API ===== | ||
+ | |||
+ | Il nous faut maintenant récupérer notre //clé API Globale// | ||
+ | |||
+ | <WRAP center> | ||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-037.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-038.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-039.png? | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | Notre //clé API Globale// apparaît. | ||
+ | |||
+ | {{Images_Cahier-101-03-008.png? | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | |{{ Images_Cahier-101-04-040.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | ===== Installation du script acme.sh ===== | ||
+ | |||
+ | La commande ci-dessous téléchargera les fichiers accompagnant '' | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# curl https:// | ||
+ | |||
+ | % Total % Received % Xferd Average Speed | ||
+ | | ||
+ | 100 | ||
+ | % Total % Received % Xferd Average Speed | ||
+ | | ||
+ | 100 174k 100 174k 0 | ||
+ | [mer. mars 13 15:34:08 EDT 2019] Installing from online archive. | ||
+ | [mer. mars 13 15:34:08 EDT 2019] Downloading https:// | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Extracting master.tar.gz | ||
+ | [mer. mars 13 15:34:09 EDT 2019] It is recommended to install socat first. | ||
+ | [mer. mars 13 15:34:09 EDT 2019] We use socat for standalone server if you use standalone mode. | ||
+ | [mer. mars 13 15:34:09 EDT 2019] If you don't use standalone mode, just ignore this warning. | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installing to / | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installed to / | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installing alias to '/ | ||
+ | [mer. mars 13 15:34:09 EDT 2019] OK, Close and reopen your terminal to start using acme.sh | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installing alias to '/ | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installing alias to '/ | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Installing cron job | ||
+ | 56 0 * * * "/ | ||
+ | [mer. mars 13 15:34:09 EDT 2019] Good, bash is found, so change the shebang to use bash as preferred. | ||
+ | [mer. mars 13 15:34:10 EDT 2019] OK | ||
+ | [mer. mars 13 15:34:10 EDT 2019] Install success! | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | On vérifie le chemin du script **acme.sh**. | ||
+ | |||
+ | < | ||
+ | root@tchana ~]# which acme.sh | ||
+ | |||
+ | alias acme.sh='/ | ||
+ | / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | ==== Configuration ==== | ||
+ | |||
+ | === Chemin des fichiers du certificat === | ||
+ | |||
+ | On doit définir certaines entrées de la base de données de configuration: | ||
+ | |||
+ | Chemin de la //**clé publique**// | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# config setprop pki CrtFile / | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | Chemin de la //**chaîne de certification**// | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# config setprop pki ChainFile / | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | Chemin de la //**clé privée**// du certificat. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# config setprop pki KeyFile / | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | === Variables d' | ||
+ | |||
+ | On doit définir certaines variables d’environnement correspondant à nos informations d’identification et à notre validateur DNS c.-à-d. // | ||
+ | |||
+ | {{Images_Cahier-101-03-003.png? | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | On exporte dans l' | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# export CF_Key=" | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | On exporte notre //adresse courriel// utilisé pour notre enregistrement chez // | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# export CF_Email=" | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | On vérifie les exportations. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# env | grep -i CF_ | ||
+ | |||
+ | CF_Email= VotreAdresseCourrielDEnregistrementChezCloudflare | ||
+ | CF_Key= VotreCléGlobaleDeCloudflare | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | {{Images_Cahier-101-03-003.png? | ||
+ | |||
+ | === Vérification de la configuration PKI === | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# config show pki | ||
+ | |||
+ | pki=configuration | ||
+ | CertificateDuration=3650 | ||
+ | ChainFile=/ | ||
+ | CommonName=Micronator | ||
+ | CountryCode=CA | ||
+ | CrtFile=/ | ||
+ | EmailAddress=VotreAdresseCourriel | ||
+ | KeyFile=/ | ||
+ | LetsEncrypt=disabled | ||
+ | LetsEncryptDomains= | ||
+ | LetsEncryptMail= | ||
+ | LetsEncryptRenewDays=30 | ||
+ | Locality=Montreal | ||
+ | Organization=RF-232 | ||
+ | OrganizationalUnitName=Service informatique | ||
+ | State=Qc | ||
+ | SubjectAltName=*.micronator-dev.org | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | \\ | ||
+ | |||
+ | ===== Demande d'un certificat ===== | ||
+ | |||
+ | On lance une demande d'un certificat de <wrap em> | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# / | ||
+ | --issue | ||
+ | --dns dns_cf | ||
+ | -d micronator-dev.org | ||
+ | -d www.micronator-dev.org | ||
+ | -d mail.micronator-dev.org | ||
+ | -d wpad.micronator-dev.org | ||
+ | --cert-file / | ||
+ | --ca-file / | ||
+ | --key-file / | ||
+ | --reloadcmd "/ | ||
+ | --test | ||
+ | |||
+ | ... | ||
+ | [mer. mars 13 17:22:51 EDT 2019] Multi domain=' | ||
+ | [mer. mars 13 17:22:51 EDT 2019] Getting domain auth token for each domain | ||
+ | ... | ||
+ | [mer. mars 13 17:22:53 EDT 2019] Found domain api file: / | ||
+ | [mer. mars 13 17:22:54 EDT 2019] Adding record | ||
+ | [mer. mars 13 17:22:54 EDT 2019] Added, OK | ||
+ | ... | ||
+ | [mer. mars 13 17:22:59 EDT 2019] Let's check each dns records now. Sleep 20 seconds first. | ||
+ | [mer. mars 13 17:23:20 EDT 2019] Checking micronator-dev.org for _acme-challenge.micronator-dev.org | ||
+ | [mer. mars 13 17:23:20 EDT 2019] Domain micronator-dev.org ' | ||
+ | ... | ||
+ | [mer. mars 13 17:23:21 EDT 2019] All success, let's return | ||
+ | [mer. mars 13 17:23:21 EDT 2019] Verifying: micronator-dev.org | ||
+ | [mer. mars 13 17:23:24 EDT 2019] Success | ||
+ | ... | ||
+ | [mer. mars 13 17:23:33 EDT 2019] Removing DNS records. | ||
+ | [mer. mars 13 17:23:39 EDT 2019] Verify finished, start to sign. | ||
+ | [mer. mars 13 17:23:39 EDT 2019] Lets finalize the order, Le_OrderFinalize: | ||
+ | [mer. mars 13 17:23:41 EDT 2019] Download cert, Le_LinkCert: | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Cert success. | ||
+ | -----BEGIN CERTIFICATE----- | ||
+ | ... | ||
+ | -----END CERTIFICATE----- | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Your cert is in / | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Your cert key is in / | ||
+ | [mer. mars 13 17:23:42 EDT 2019] The intermediate CA cert is in / | ||
+ | [mer. mars 13 17:23:42 EDT 2019] And the full chain certs is there: | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Installing cert to:/ | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Installing CA to:/ | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Installing key to:/ | ||
+ | [mer. mars 13 17:23:42 EDT 2019] Run reload cmd: / | ||
+ | [mer. mars 13 17:23:45 EDT 2019] Reload success | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | La demande d'un certificat de //TEST// a réussi, on peut faire une demande de certificat de <wrap em> | ||
+ | |||
+ | {{Images_Cahier-101-03-004.png? | ||
+ | |||
+ | On lance une demande d'un certificat TLS de // | ||
+ | |||
+ | Il faut ajouter le paramètre '' | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# / | ||
+ | --issue | ||
+ | --dns dns_cf | ||
+ | -d micronator-dev.org | ||
+ | -d www.micronator-dev.org | ||
+ | -d mail.micronator-dev.org | ||
+ | -d wpad.micronator-dev.org | ||
+ | --cert-file / | ||
+ | --ca-file / | ||
+ | --key-file / | ||
+ | --reloadcmd "/ | ||
+ | --force | ||
+ | |||
+ | [mer. mars 13 18:25:33 EDT 2019] Multi domain=' | ||
+ | [mer. mars 13 18:25:33 EDT 2019] Getting domain auth token for each domain | ||
+ | ... | ||
+ | [mer. mars 13 18:25:36 EDT 2019] Adding record | ||
+ | [mer. mars 13 18:25:37 EDT 2019] Added, OK | ||
+ | ... | ||
+ | [mer. mars 13 18:25:39 EDT 2019] Let's check each dns records now. Sleep 20 seconds first. | ||
+ | [mer. mars 13 18:26:01 EDT 2019] Checking micronator-dev.org for _acme-challenge.micronator-dev.org | ||
+ | [mer. mars 13 18:26:01 EDT 2019] Domain micronator-dev.org ' | ||
+ | ... | ||
+ | [mer. mars 13 18:26:01 EDT 2019] All success, let's return | ||
+ | [mer. mars 13 18:26:01 EDT 2019] Verifying: micronator-dev.org | ||
+ | [mer. mars 13 18:26:04 EDT 2019] Success | ||
+ | ... | ||
+ | [mer. mars 13 18:26:10 EDT 2019] Removing DNS records. | ||
+ | [mer. mars 13 18:26:14 EDT 2019] Verify finished, start to sign. | ||
+ | [mer. mars 13 18:26:14 EDT 2019] Lets finalize the order, Le_OrderFinalize: | ||
+ | [mer. mars 13 18:26:15 EDT 2019] Download cert, Le_LinkCert: | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Cert success. | ||
+ | -----BEGIN CERTIFICATE----- | ||
+ | ... | ||
+ | -----END CERTIFICATE----- | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Your cert is in / | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Your cert key is in / | ||
+ | [mer. mars 13 18:26:16 EDT 2019] The intermediate CA cert is in / | ||
+ | [mer. mars 13 18:26:16 EDT 2019] And the full chain certs is there: | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Installing cert to:/ | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Installing CA to:/ | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Installing key to:/ | ||
+ | [mer. mars 13 18:26:16 EDT 2019] Run reload cmd: / | ||
+ | [mer. mars 13 18:26:18 EDT 2019] Reload success | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | // | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ===== Vérification ===== | ||
+ | |||
+ | __**À la console du serveur**__ | ||
+ | |||
+ | // | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# ls -als / | ||
+ | |||
+ | 4 -rw-r--r-- 1 root root 2021 13 mars 18:26 / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | //**Chaîne de certification**// | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# ls -als / | ||
+ | |||
+ | 4 -rw-r--r-- 1 root root 1648 13 mars 18:26 / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | //**Clé privée**// | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# ls -als / | ||
+ | |||
+ | 4 -rw------- 1 root root 1675 13 mars 18:26 / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | |||
+ | __**Avec un navigateur**__ | ||
+ | |||
+ | On se rend à https:// | ||
+ | |||
+ | Il n'est pas nécessaire d' | ||
+ | |||
+ | <WRAP centeralign> | ||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | </ | ||
+ | |||
+ | {{ Images_Cahier-101-04-041.png? | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | \\ | ||
+ | **Plus d' | ||
+ | |{{ Images_Cahier-101-04-042.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | \\ | ||
+ | \\ | ||
+ | Onglet **Sécurité | ||
+ | |{{ Images_Cahier-101-04-043.png? | ||
+ | </ | ||
+ | <WRAP column 30%> | ||
+ | < | ||
+ | < | ||
+ | |{{ Images_Cahier-101-04-044.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | <WRAP column 40%> | ||
+ | < | ||
+ | |||
+ | < | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | |{{ Images_Cahier-101-04-045.png? | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | \\ | ||
+ | |||
+ | ===== Renouvellement ===== | ||
+ | |||
+ | À chaque jour, une //tâche cron// vérifie le nombre de jours restant pour la validité. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# crontab -l | ||
+ | |||
+ | 56 0 * * * "/ | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | {{Images_Cahier-101-03-005.png? | ||
+ | |||
+ | On peut forcer le renouvellement en //mode TEST//. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# acme.sh --renew | ||
+ | -d micronator-dev.org | ||
+ | -d www.micronator-dev.org | ||
+ | -d mail.micronator-dev.org \ | ||
+ | -d wpad.micronator-dev.org \ | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | On peut aussi forcer le renouvellement en //mode Production// | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# acme.sh --renew | ||
+ | -d micronator-dev.org | ||
+ | -d www.micronator-dev.org | ||
+ | -d mail.micronator-dev.org \ | ||
+ | -d wpad.micronator-dev.org \ | ||
+ | | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | <WRAP centeralign> | ||
+ | \\ | ||
+ | |||
+ | ===== Répertoire well-known ===== | ||
+ | |||
+ | // | ||
+ | // | ||
+ | |||
+ | Pour un serveur __branché directement à l' | ||
+ | |||
+ | On peut faire la demande de certificat à la page de l' | ||
+ | |||
+ | Pour ce genre de serveur //(branché directement à l' | ||
+ | |||
+ | ==== Création du fichier z_well-known.conf ==== | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | < | ||
+ | cat > / | ||
+ | Alias "/ | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | EOT | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | On vérifie. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# ls -als / | ||
+ | |||
+ | 4 -rw-r--r-- 1 root root 231 10 juin 11:03 / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | On affiche le contenu du fichier. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# cat / | ||
+ | |||
+ | Alias "/ | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | === Sauvegarde du fichier === | ||
+ | |||
+ | On vérifie si le nom du fichier ''/ | ||
+ | |||
+ | {{Images_Cahier-101-03-006.png? | ||
+ | |||
+ | < | ||
+ | NouvelleInclusion="/ | ||
+ | if grep -Fxq " | ||
+ | then | ||
+ | # L' | ||
+ | echo -e "\nLe fichier custom.include contient déjà l' | ||
+ | else | ||
+ | # L' | ||
+ | echo -e " | ||
+ | echo -e " | ||
+ | fi | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | On vérifie. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# cat / | ||
+ | |||
+ | / | ||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | |||
+ | Ci-dessus, il n'y a pas de ligne vide avant //< | ||
+ | |||
+ | === Redémarrage du démon httpd === | ||
+ | |||
+ | On redémarre le démon //Apache// afin qu'il relise ses fichiers de configuration. | ||
+ | |||
+ | < | ||
+ | [root@tchana ~]# systemctl restart httpd | ||
+ | |||
+ | [root@tchana ~]# | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | {{NS-101_002_Banniere_Victoire.png? | ||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Crédits ====== | ||
+ | |||
+ | © 2016-2017-2018-2019 | ||
+ | Auteur: Michel-André CLP.\\ | ||
+ | Remerciement: | ||
+ | Intégré par: Michel-André Robillard CLP.\\ | ||
+ | Contact: michelandre at micronator.org | ||
+ | |||
+ | Répertoire de ce document: < | ||
+ | |||
+ | ===== Historique des modifications ===== | ||
+ | |||
+ | ^Version^Date^Commentaire^Auteur| | ||
+ | |0.0.1|2016-01-26|Début.|Michel-André| | ||
+ | |0.0.2|2016-03-21|Ajustement de la tâche cron, pour qu’elle roule quotidiennement à 02h15, à cause de la possibilité d’un “effet de bord” du programme calculant le nombre de jours restants pour la validité du certificat.|Michel-André| | ||
+ | |0.0.3|2016-04-03|Corrections orthographiques.|Michel-André| | ||
+ | |0.1.0|2016-04-03| - Mise à jour à cause du changement du nom du fichier de configuration de config.sh à config.\\ - La majorité des dates, heures et certificats sont ceux de la __version 0.0.1 de ce document__.|Michel-André| | ||
+ | |0.1.1|2016-07-18| Correction pour le fichier **/ | ||
+ | |0.2.0|2016-09-14| Ajustement pour le changement de nom du client **letsencrypt.sh** pour **dehydrated**.|Michel-André| | ||
+ | |1.0.0|2017-01-30| Mise à jour pour le cours Micronator**-10****1**.|Michel-André| | ||
+ | |1.1.0|2018-03-24|Mise à jour de certaines figures et correction de quelques coquilles.|Michel-André| | ||
+ | |2.0.0|2018-10-02|Mise à jour en utilisant la Contrib Let's Encrypt.|Michel-André| | ||
+ | |2.0.1|2018-11-07|Corrections mineures.|Michel-André| | ||
+ | |3.0.0|2019-03-09|Adaptation pour NethServer-7.6.1810.|Michel-André| | ||
+ | |3.0.1|2019-05-06|Corrections mineures.|Michel-André| | ||
+ | |3.0.2|2019-06-16|- Corrections mineures.\\ - Ajout d'une section pour le répertoire .well-known d'un serveur branché directement à l' | ||
+ | |3.1.0|2019-08-04|Corrections mineures pour DokuWiki.|Michel-André| | ||
+ | |12345678901| | |12345678901| | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | ===== AVIS DE NON-RESPONSABILITÉ ===== | ||
+ | |||
+ | Ce document est uniquement destiné à informer. Les informations, | ||
+ | |||
+ | RF‑232 ne peut être tenu pour responsable de dommages de quelque nature que ce soit, y compris des dommages directs ou indirects, ainsi que des dommages consécutifs résultant de l' | ||
+ | |||
+ | Chaque internaute doit prendre toutes les mesures appropriées //(mettre à jour régulièrement son logiciel antivirus, ne pas ouvrir des documents suspects de source douteuse ou non connue)// de façon à protéger le contenu de son ordinateur de la contamination d' | ||
+ | |||
+ | Toute reproduction interdite | ||
+ | Vous reconnaissez et acceptez que tout le contenu de ce document, incluant mais sans s’y limiter, le texte et les images, sont protégés par le droit d’auteur, les marques de commerce, les marques de service, les brevets, les secrets industriels et les autres droits de propriété intellectuelle. Sauf autorisation expresse de RF-232, vous acceptez de ne pas vendre, délivrer une licence, louer, modifier, distribuer, copier, reproduire, transmettre, | ||
+ | |||
+ | ==== Avertissement==== | ||
+ | |||
+ | Bien que nous utilisions ici un vocabulaire issu des techniques informatiques, | ||
+ | \\ | ||
+ | \\ |