.pfx to base64 to .pfx

Issue: We don’t want to store our .pfx certificates in any Build servers or in code base.

Solution: Maintain .pfx certificates in the base64 encoded format on Build servers and then generate .pfx during deployment phase.

Note: You have to make use of this powershell script on your daily build definition to generate .pfx certificate from base64 string.

So let us see how we do this encoding and decoding of .pfx certificate.

$bytes = [System.IO.File]::ReadAllBytes(“C:\temp\Authentication.pfx”)

$base64String = [System.Convert]::ToBase64String($bytes);

Write-Output “Below is the Output of encoded base64 string”
Write-Output $base64String


[IO.File]::WriteAllBytes($outputFilename, $decodedString)

Write-Output “<<=====================================>>>”
Write-Output “Done Saving PFX file”



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s