Skip to content

Commit 4dad28b

Browse files
authored
Merge pull request #120286 from BethanyZhou/patch-2
Update how-to-export-certificate.md
2 parents bbb396b + 68b895b commit 4dad28b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

articles/key-vault/certificates/how-to-export-certificate.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,10 @@ $certificateName = '<YourCert>'
8484
$password = '<YourPwd>'
8585
8686
$pfxSecret = Get-AzKeyVaultSecret -VaultName $vaultName -Name $certificateName -AsPlainText
87-
$secretByte = [Convert]::FromBase64String($pfxSecret)
88-
$x509Cert = New-Object Security.Cryptography.X509Certificates.X509Certificate2
89-
$x509Cert.Import($secretByte, $null, [Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
90-
$pfxFileByte = $x509Cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $password)
87+
$certBytes = [Convert]::FromBase64String($pfxSecret)
9188
9289
# Write to a file
93-
[IO.File]::WriteAllBytes("KeyVaultcertificate.pfx", $pfxFileByte)
90+
Set-Content -Path cert.pfx -Value $certBytes -AsByteStream
9491
9592
```
9693

0 commit comments

Comments
 (0)