-
-
Save huyttq/d6691084a2b1621cd9d033678bf85ffa to your computer and use it in GitHub Desktop.
PowerShell script that imports a .pfx certificate file. Useful to do before building the solution on a build server.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($PfxFilePath, $Password) | |
$absolutePfxFilePath = Resolve-Path -Path $PfxFilePath | |
Write-Output "Importing store certificate '$absolutePfxFilePath'..." | |
Add-Type -AssemblyName System.Security | |
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 | |
$cert.Import($absolutePfxFilePath, $Password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet") | |
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser | |
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::"ReadWrite") | |
$store.Add($cert) | |
$store.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment