Blue Azure dev ops image

Convert PFX Certificate to Base64 String

When working on Azure DevOps test plans, oftentimes you’d have to secure the communication between the resources using certificates.

For example, when establishing a secure connection between your VSTS build server and Service Fabric cluster on Azure, you’ll have to give the Base64 encoded version of the pfx certificate that you’ve used to secure the service fabric cluster.

That way, your build server will be able to securely connect to the cluster to deploy packages or other artifacts.

Converting the pfx certificate to the Base64 encoded string is really easy using powershell.

1$fileContentBytes = get-content 'C:\Techfabric\TFProcess\Articles\convert\test-cert.pfx' -Encoding Byte
2[System.Convert]::ToBase64String($fileContentBytes) | Out-File 'pfx-encoded-bytes.txt'
Converting the pfx certificate to the Base64 encoded string
Converting the pfx certificate to the Base64 encoded string

The text file with the necessary bytes will be created in the same folder where the script is run.

Enjoy!



Preetham Reddy, Cloud Solutions Architect at TechFabric


TechFabric specializes in building web, mobile and cloud based application using Microsoft Stack (C#, .NET Core, Xamarin, Azure, SQL Service etc.,). If you need help with taking your on-premise application to cloud or convert your monolithic applications to microservices based, we’d be glad to help you out.You can reach out to our sales team at contact@techfabric.com.

Interested in learning more about this topic? Contact our solution experts and setup a time to talk.