Migration PNCN » Historique » Version 2
Fabrice Barconnière, 08/02/2016 14:57
| 1 | 1 | Fabrice Barconnière | h1. Certificats VPN et migration PNCN |
|---|---|---|---|
| 2 | 1 | Fabrice Barconnière | |
| 3 | 1 | Fabrice Barconnière | h2. But |
| 4 | 1 | Fabrice Barconnière | |
| 5 | 1 | Fabrice Barconnière | * Mise en conformité selon les préconisations de l'ANSSI |
| 6 | 1 | Fabrice Barconnière | * Utiliser des certificats sha2 |
| 7 | 1 | Fabrice Barconnière | |
| 8 | 1 | Fabrice Barconnière | h2. Prérequis |
| 9 | 1 | Fabrice Barconnière | |
| 10 | 1 | Fabrice Barconnière | * Sphynx 2.4.2 (2.5.2 bientôt stable) |
| 11 | 1 | Fabrice Barconnière | * Amon 2.4.0 minimum (2.5 recommandé) |
| 12 | 1 | Fabrice Barconnière | |
| 13 | 1 | Fabrice Barconnière | h2. Paramétrage du serveur Sphynx |
| 14 | 1 | Fabrice Barconnière | |
| 15 | 1 | Fabrice Barconnière | Le serveur doit être paramétré pour être conforme à l'IGC PNCN. |
| 16 | 1 | Fabrice Barconnière | Lancer *gen_config* pour vérifier et adapter la configuration : |
| 17 | 1 | Fabrice Barconnière | * Onglet *Vpn-pki* |
| 18 | 1 | Fabrice Barconnière | ** *Utiliser la PKI PNCN* à *oui* |
| 19 | 1 | Fabrice Barconnière | ** *Localité (L=)* doit être renseigné avec une *ville* |
| 20 | 1 | Fabrice Barconnière | ** *Nom de l'organisation (O=)* doit contenir *Education Nationale* |
| 21 | 1 | Fabrice Barconnière | ** *Nom de l'unité de l'organisation (OU=)* doit contenir *0002 110043015* et *Academie de ....* |
| 22 | 1 | Fabrice Barconnière | ** *URL des listes de révocation de certificats (sinon rien)* est optionnel, elles sont présentes dans chaque certificat |
| 23 | 1 | Fabrice Barconnière | |
| 24 | 1 | Fabrice Barconnière | Lancer *reconfigure* pour prendre en compte ces modifications. |
| 25 | 1 | Fabrice Barconnière | |
| 26 | 1 | Fabrice Barconnière | Cela permet de : |
| 27 | 1 | Fabrice Barconnière | * générer une configuration openssl conforme pour les requêtes de certificats auprès de la PNCN |
| 28 | 1 | Fabrice Barconnière | * configurer ARV pour forcer un suffixe DNS au CN du certificat lors de la génération d'une requête |
| 29 | 1 | Fabrice Barconnière | |
| 30 | 1 | Fabrice Barconnière | h2. Mise à niveau des versions des serveurs EOLE |
| 31 | 1 | Fabrice Barconnière | |
| 32 | 1 | Fabrice Barconnière | Le serveur Sphynx doit être en version 2.4.2 minimum. |
| 33 | 1 | Fabrice Barconnière | Les serveurs Amon doivent être en version 2.4.x minimum. |
| 34 | 1 | Fabrice Barconnière | |
| 35 | 1 | Fabrice Barconnière | * Vous disposez d'un Sphynx version 2.2 ou inférieur : |
| 36 | 1 | Fabrice Barconnière | ** Réinstallation du serveur Sphynx |
| 37 | 1 | Fabrice Barconnière | * Vous disposez d'un Sphynx 2.3, 2.4.0 ou 2.4.1, 3 possibilités : |
| 38 | 1 | Fabrice Barconnière | ** Réinstallation du serveur Sphynx |
| 39 | 1 | Fabrice Barconnière | ** Migration du serveur existant |
| 40 | 1 | Fabrice Barconnière | ** Sauvegarde + réinstallation + restauration |
| 41 | 1 | Fabrice Barconnière | |
| 42 | 1 | Fabrice Barconnière | * Vous disposez de serveurs Amon version 2.2 ou inférieur : |
| 43 | 1 | Fabrice Barconnière | ** Réinstallation du serveur au moment du passage à la PNCN |
| 44 | 1 | Fabrice Barconnière | |
| 45 | 1 | Fabrice Barconnière | * Vous disposez de serveurs Amon 2.3, 2 possibilités : |
| 46 | 1 | Fabrice Barconnière | ** Réinstallation du serveur, même avant le passage à la PNCN |
| 47 | 1 | Fabrice Barconnière | ** Migration du serveur existant, même avant le passage à la PNCN |
| 48 | 1 | Fabrice Barconnière | |
| 49 | 1 | Fabrice Barconnière | Durées des migrations (procédure *Upgrade-Auto*) : |
| 50 | 1 | Fabrice Barconnière | * Amon/Sphynx 2.3 vers Amon/Sphynx 2.4.2 : 1 heure |
| 51 | 1 | Fabrice Barconnière | * Amon/Sphynx 2.4.x vers Amon/Sphynx 2.4.2 : 5 à 10 minutes |
| 52 | 1 | Fabrice Barconnière | |
| 53 | 1 | Fabrice Barconnière | Opérations post-migration : |
| 54 | 1 | Fabrice Barconnière | * reboot |
| 55 | 1 | Fabrice Barconnière | * gen_config avec connexion Zéphir (adapter la configuration sur Sphynx) |
| 56 | 1 | Fabrice Barconnière | * instance |
| 57 | 1 | Fabrice Barconnière | * Régénérer la configuration IPsec : |
| 58 | 1 | Fabrice Barconnière | ** Pour Sphynx : se connecter sur ARV et cliquer sur *Appliquer* |
| 59 | 1 | Fabrice Barconnière | ** Pour Amon : lancer *active_rvp init* (un redémarrage de *bastion* peut-être nécessaire la première fois) |
| 60 | 1 | Fabrice Barconnière | |
| 61 | 1 | Fabrice Barconnière | h2. Prise en compte de la PNCN |
| 62 | 1 | Fabrice Barconnière | |
| 63 | 1 | Fabrice Barconnière | Dans ARV, un modèle de lien associé à l'autorité de certification *AC EN Scolarite et Formation* doit exister. |
| 64 | 1 | Fabrice Barconnière | |
| 65 | 1 | Fabrice Barconnière | * Sur une primo installation d'un serveur Sphynx 2.4.2 : |
| 66 | 1 | Fabrice Barconnière | ** enregistrer le serveur sur Zéphir |
| 67 | 1 | Fabrice Barconnière | ** lancer le script *init_sphynx* pour créer le modèle de lien |
| 68 | 1 | Fabrice Barconnière | |
| 69 | 1 | Fabrice Barconnière | * Sur un serveur Sphynx déjà en production, encore configuré pour *RACINE AGRIATES* (migration ou réinstallation) : |
| 70 | 1 | Fabrice Barconnière | ** configurer le serveur pour utiliser la PNCN |
| 71 | 1 | Fabrice Barconnière | ** lancer le script *init_pncn* pour : |
| 72 | 1 | Fabrice Barconnière | *** cloner les modèles de liens existants associés à l'AC *RACINE AGRIATES* |
| 73 | 1 | Fabrice Barconnière | *** associer *AC EN Scolarite et Formation* à ces modèles clonés |
| 74 | 1 | Fabrice Barconnière | *** renommer les modèles de liens existants associés à l'AC *RACINE AGRIATES* en les préfixant par *OLD_PKI_* |
| 75 | 1 | Fabrice Barconnière | |
| 76 | 1 | Fabrice Barconnière | On pourra ainsi utiliser les deux PKI simultanément et procéder à une migration progressive. |
| 77 | 1 | Fabrice Barconnière | Sphynx peut avoir des connexions VPN basés sur *RACINE AGRIATES* et *AC EN Scolarite et Formation*. |
| 78 | 1 | Fabrice Barconnière | |
| 79 | 1 | Fabrice Barconnière | h2. Importer les certificats p12 fournis par la PNCN |
| 80 | 1 | Fabrice Barconnière | |
| 81 | 1 | Fabrice Barconnière | L'importation de fichiers pkcs12 n'est pas prévue dans ARV. Ce format inclus la chaîne de certification jusqu'au certificat final ainsi que la clé privée. |
| 82 | 1 | Fabrice Barconnière | ARV peut importer les certificats et les clés privées mais dans des fichiers séparés. Il va falloir transformer ce fichier pksc12 en deux fichiers que ARV pourra importer. |
| 83 | 2 | Fabrice Barconnière | * "Script de conversion du fichier pkcs12":https://dev-eole.ac-dijon.fr/attachments/download/1550/split_pkcs12 |
| 84 | 1 | Fabrice Barconnière | <pre> |
| 85 | 1 | Fabrice Barconnière | #!/bin/bash |
| 86 | 1 | Fabrice Barconnière | |
| 87 | 1 | Fabrice Barconnière | # Extraction de la chaîne de certification dans un fichier PKCS7 PEM |
| 88 | 1 | Fabrice Barconnière | # Extraction et chiffrement de la clé privée dans un fichier RSA PEM |
| 89 | 1 | Fabrice Barconnière | |
| 90 | 1 | Fabrice Barconnière | if [[ $# -ne 3 ]] |
| 91 | 1 | Fabrice Barconnière | then |
| 92 | 1 | Fabrice Barconnière | echo "Génération d'un fichier pksc7 et d'un fichier rsa |
| 93 | 1 | Fabrice Barconnière | argument 1 : fichier pkcs12 |
| 94 | 1 | Fabrice Barconnière | argument 2 : mot de passe du fichier pkcs12 |
| 95 | 1 | Fabrice Barconnière | argument 3 : mot de passe pour chiffrer la clé privée |
| 96 | 1 | Fabrice Barconnière | " |
| 97 | 1 | Fabrice Barconnière | exit 0 |
| 98 | 1 | Fabrice Barconnière | fi |
| 99 | 1 | Fabrice Barconnière | |
| 100 | 1 | Fabrice Barconnière | if [ ! -f $1 ] |
| 101 | 1 | Fabrice Barconnière | then |
| 102 | 1 | Fabrice Barconnière | echo "fichier $1 inexistant !!!" |
| 103 | 1 | Fabrice Barconnière | exit 1 |
| 104 | 1 | Fabrice Barconnière | fi |
| 105 | 1 | Fabrice Barconnière | |
| 106 | 1 | Fabrice Barconnière | TMP_CERT_FILE="certs.tmp" |
| 107 | 1 | Fabrice Barconnière | CERT_FILENAME=$(basename $1 | sed -e 's/\.p12$//') |
| 108 | 1 | Fabrice Barconnière | PKCS7_FILENAME="${CERT_FILENAME}.p7" |
| 109 | 1 | Fabrice Barconnière | PRIVKEY_FILENAME="priv-${CERT_FILENAME}.pem" |
| 110 | 1 | Fabrice Barconnière | |
| 111 | 1 | Fabrice Barconnière | # Extraction certificats + clé privée + chiffrement clé dans la foulée |
| 112 | 1 | Fabrice Barconnière | openssl pkcs12 -in $1 -passin pass:$2 -passout pass:$3 -out $TMP_CERT_FILE |
| 113 | 1 | Fabrice Barconnière | if [[ $? -ne 0 ]] |
| 114 | 1 | Fabrice Barconnière | then |
| 115 | 1 | Fabrice Barconnière | exit $? |
| 116 | 1 | Fabrice Barconnière | fi |
| 117 | 1 | Fabrice Barconnière | |
| 118 | 1 | Fabrice Barconnière | # On ne conserve que les lignes utiles |
| 119 | 1 | Fabrice Barconnière | sed -i '/-----BEGIN/,/-----END/!d' $TMP_CERT_FILE |
| 120 | 1 | Fabrice Barconnière | # Extraction de la clé privée chiffrée dans un fichier |
| 121 | 1 | Fabrice Barconnière | sed -e '/-----BEGIN ENCRYPTED PRIVATE KEY-----/,/-----END ENCRYPTED PRIVATE KEY-----/!d' $TMP_CERT_FILE > $PRIVKEY_FILENAME |
| 122 | 1 | Fabrice Barconnière | echo "Clé privée : $PRIVKEY_FILENAME" |
| 123 | 1 | Fabrice Barconnière | # On ne conserve que les certificats |
| 124 | 1 | Fabrice Barconnière | sed -i '/-----BEGIN ENCRYPTED PRIVATE KEY-----/,/-----END ENCRYPTED PRIVATE KEY-----/d' $TMP_CERT_FILE |
| 125 | 1 | Fabrice Barconnière | # Création d'un fichier pkcs7 contenant la chaîne de certification |
| 126 | 1 | Fabrice Barconnière | openssl crl2pkcs7 -nocrl -out $PKCS7_FILENAME -certfile $TMP_CERT_FILE |
| 127 | 1 | Fabrice Barconnière | if [[ $? -ne 0 ]] |
| 128 | 1 | Fabrice Barconnière | then |
| 129 | 1 | Fabrice Barconnière | exit $? |
| 130 | 1 | Fabrice Barconnière | fi |
| 131 | 1 | Fabrice Barconnière | echo "Fichier PKCS7 : $PKCS7_FILENAME" |
| 132 | 1 | Fabrice Barconnière | |
| 133 | 1 | Fabrice Barconnière | rm -rf $TMP_CERT_FILE |
| 134 | 1 | Fabrice Barconnière | </pre> |
| 135 | 1 | Fabrice Barconnière | |
| 136 | 1 | Fabrice Barconnière | h2. Génération de la configuration IPsec pour la PNCN |
| 137 | 1 | Fabrice Barconnière | |
| 138 | 1 | Fabrice Barconnière | Dans l'application ARV, il doit exister un modèle de lien basé sur *AC EN Scolarite et Formation*. |
| 139 | 1 | Fabrice Barconnière | Les serveurs doivent disposer de certificats issus de *AC EN Scolarite et Formation*. |