reseau:cloud:azure:configurerapppoursharepoint
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 | ||
| reseau:cloud:azure:configurerapppoursharepoint [2026/04/06 12:31] – [Utilisation d'un certificat] techer.charles_educ-valadon-limoges.fr | reseau:cloud:azure:configurerapppoursharepoint [2026/04/10 22:24] (Version actuelle) – [Utilisation d'un certificat] techer.charles_educ-valadon-limoges.fr | ||
|---|---|---|---|
| Ligne 123: | Ligne 123: | ||
| $cert.HasPrivateKey doit renvoyer True | $cert.HasPrivateKey doit renvoyer True | ||
| - | + | === Export du certificat PUBLIC | |
| - | * Export du certificat PUBLIC à importer dans Entra ID | + | |
| < | < | ||
| Ligne 160: | Ligne 159: | ||
| CertificateThumbprint | CertificateThumbprint | ||
| </ | </ | ||
| + | |||
| + | === Exporter le certificat pour obtenir un PFX PKCS#1 (clé privée incluse) === | ||
| + | |||
| + | |||
| + | < | ||
| + | $thumb = " | ||
| + | |||
| + | $cert = Get-Item " | ||
| + | |||
| + | Export-PfxCertificate ` | ||
| + | -Cert $cert ` | ||
| + | -FilePath " | ||
| + | -Password (ConvertTo-SecureString -String " | ||
| + | </ | ||
| + | |||
| + | === Importer un PFX sur une autre machine === | ||
| + | |||
| + | < | ||
| + | Import-PfxCertificate ` | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | === Générer une clé PKCS#8 === | ||
| + | |||
| + | * Recharger le PFX | ||
| + | |||
| + | < | ||
| + | $pfxPath = " | ||
| + | $pfxPassword = " | ||
| + | |||
| + | $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2( | ||
| + | $pfxPath, | ||
| + | $pfxPassword, | ||
| + | [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]:: | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | * Récupérer la clé privée RSA | ||
| + | |||
| + | < | ||
| + | $rsa = $cert.PrivateKey | ||
| + | </ | ||
| + | |||
| + | * Exporter la clé AU FORMAT PKCS#8 | ||
| + | |||
| + | < | ||
| + | # Récupère les paramètres | ||
| + | $params = $rsa.ExportParameters($true) | ||
| + | |||
| + | # Crée un RSA moderne | ||
| + | $rsa2 = [System.Security.Cryptography.RSA]:: | ||
| + | $rsa2.ImportParameters($params) | ||
| + | |||
| + | # Export PKCS#8 | ||
| + | $pkcs8 = $rsa2.ExportPkcs8PrivateKey() | ||
| + | |||
| + | $base64 = [System.Convert]:: | ||
| + | $pkcs8, | ||
| + | [System.Base64FormattingOptions]:: | ||
| + | ) | ||
| + | |||
| + | |||
| + | $pem = @" | ||
| + | -----BEGIN PRIVATE KEY----- | ||
| + | $base64 | ||
| + | -----END PRIVATE KEY----- | ||
| + | "@ | ||
| + | |||
| + | $pem | Set-Content ` | ||
| + | -Path C: | ||
| + | -Encoding ASCII | ||
| + | </ | ||
| + | |||
| + | === Résumé .cer .pfx === | ||
| + | |||
| + | <WRAP center round info> | ||
| + | Un fichier .cer contient uniquement la **clé publique du certificat**. Cela permet : | ||
| + | * de déclarer le certificat dans Entra ID | ||
| + | * permet à Microsoft de vérifier les signatures | ||
| + | |||
| + | La clé privée est déjà stockée dans Windows : | ||
| + | * dans **Cert: | ||
| + | * aucun PFX n’est nécessaire tant que l'on se connecte depuis le PC où se trouve la clé privée. En indiquant l' | ||
| + | |||
| + | Un fichier .cer ne permet pas : | ||
| + | * de s’authentifier | ||
| + | * de signer | ||
| + | |||
| + | Un fichier .pfx (format PFX / PKCS#12) contient : | ||
| + | * la clé publique | ||
| + | * la clé privée | ||
| + | * (optionnel) la chaîne de certificats | ||
| + | * et est protégé par une passphrase | ||
| + | |||
| + | C’est le seul format portable qui permet : | ||
| + | * d’importer un certificat avec clé privée | ||
| + | * d’authentifier une application sur une autre machine | ||
| + | * d’utiliser le certificat sur Linux / AWX / Docker / CI/CD | ||
| + | |||
| + | ^ Format | ||
| + | |.cer|clé publique|Entra ID, SharePoint| | ||
| + | |.pfx|clé publique + clé privée|Authentification| | ||
| + | |.pfx + mdp|portable sécurisé|Serveur, | ||
| + | </ | ||
| + | |||
| ==== Donner accès à l' | ==== Donner accès à l' | ||
| Ligne 191: | Ligne 297: | ||
| < | < | ||
| Connect-MgGraph ` | Connect-MgGraph ` | ||
| - | | + | -TenantId "< |
| - | -ClientId "5c82fc87-6e0c-413f-ac12-6d784af9a249" ` | + | |
| - | -CertificateThumbprint "97F825CFD5C0371D28E1D691140A084B9C2C4386" | + | |
| </ | </ | ||
reseau/cloud/azure/configurerapppoursharepoint.1775471466.txt.gz · Dernière modification : 2026/04/06 12:31 de techer.charles_educ-valadon-limoges.fr
