当您将PFX转换为Base64,然后将其转换回PFX时,是否有可能?
$PFX_FILE = get-content 'dummy.pfx' -Encoding Byte
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($PFX_FILE)) | Out-File 'dummy.txt'
$BASE64_STR = get-content 'dummy.txt' -Encoding utf8
[Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($BASE64_STR)) | Out-File 'dummy-2.pfx'第四行的输出是毫不奇怪的无效的,但我不知道如何进行。
发布于 2021-02-17 10:56:14
我在位置创建了一个PFX证书: C:\temp\PowerShellGraphCert.pfx,并运行了以下命令。我相信这就是你要找的。我将> PowerShellGraphCert.pfx转换为PowerShellGraphCert.txt,然后返回到虚拟-3.pfx。Now PowerShellGraphCert.pfx =dummy 3.pfx
$PFX_FILE = get-content 'C:\temp\PowerShellGraphCert.pfx' -Encoding Byte
$base64 = [System.Convert]::ToBase64String($PFX_FILE) | Out-File 'C:\temp\PowerShellGraphCertbase64.txt'
$BASE64_STR = get-content 'C:\temp\PowerShellGraphCertbase64.txt'
$filename = 'C:\temp\dummy-3.pfx'
$bytes = [Convert]::FromBase64String($BASE64_STR)
[IO.File]::WriteAllBytes($filename, $bytes)

https://stackoverflow.com/questions/66239147
复制相似问题