Base-64 encoded form of the .pfx file
Asked Answered
S

2

8

How to get the base 64 encoded form of .pfx file?

I am trying to implement one of the azure resource manager templates

"certData": {
      "type": "string",
      "metadata": {
        "description": "Base-64 encoded form of the .pfx file"
      }
    }

You can see the cert data wants that information.

Semiquaver answered 26/10, 2017 at 16:54 Comment(0)
P
36

According to your description, I suggest you could try to use below powershell command to generate the Base-64 encoded string.

$fileContentBytes = get-content 'D:\brando.pfx' -Encoding Byte

[System.Convert]::ToBase64String($fileContentBytes) | Out-File 'D:\pfx-bytes.txt'

It will convert the pfx to Base-64 encoded string in a txt file.

Pubes answered 27/10, 2017 at 2:38 Comment(4)
i don't use windows OS ,can you suggest for linux or macOSSemiquaver
You could try to use base64 [OPTION]... [FILE] to encode the pfx file. More details, you could refer to this article.Pubes
If you're using Powershell Core (Windows Terminal) then in the first command instead of "-Encoding Byte" param you should use "-AsByteStream".Marsha
It appears that -Encoding is no longer valid. What would be the new command?Tapeworm
U
5

For Powershell Core (6+) you need to use

$fileContentBytes = Get-Content 'path-to.pfx' -AsByteStream

[System.Convert]::ToBase64String($fileContentBytes) | Out-File 'pfx-bytes.txt'
Underpants answered 26/4, 2023 at 15:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.