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/10 22:04] – [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 160: | Ligne 160: | ||
| </ | </ | ||
| - | === Exporter le certificat pour obtenir un PFX (clé privée incluse) === | + | === Exporter le certificat pour obtenir un PFX PKCS# |
| Ligne 172: | Ligne 172: | ||
| -FilePath " | -FilePath " | ||
| -Password (ConvertTo-SecureString -String " | -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 | ||
| </ | </ | ||
reseau/cloud/azure/configurerapppoursharepoint.1775851440.txt.gz · Dernière modification : 2026/04/10 22:04 de techer.charles_educ-valadon-limoges.fr
