【问题标题】:How can I retrieve the PFX Password of a generated Azure Key Vault certificate?如何检索生成的 Azure Key Vault 证书的 PFX 密码?
【发布时间】:2021-02-23 09:06:49
【问题描述】:

Azure Key Vault 允许您直接在 GUI 中生成证书。之后,您可以将这些证书下载为 pfx 文件。

这些 pfx 文件是否受密码保护?我正在尝试在某处使用此证书,它不会让我在没有密码的情况下继续操作。

【问题讨论】:

    标签: azure azure-keyvault


    【解决方案1】:

    使用 AzureRM 的以下 PowerShell 脚本,我可以使用密码从 Key Vault 导出 pfx:

    # Replace these variables with your own values
    $vaultName = "<KEY_VAULT>"
    $certificateName = "<CERTIFICATE_NAME>"
    $pfxPath = [Environment]::GetFolderPath("Desktop") + "\$certificateName.pfx"
    $password = "<PASSWORD>"
    
    $pfxSecret = Get-AzureKeyVaultSecret -VaultName $vaultName -Name $certificateName
    $pfxUnprotectedBytes = [Convert]::FromBase64String($pfxSecret.SecretValueText)
    $pfx = New-Object Security.Cryptography.X509Certificates.X509Certificate2
    $pfx.Import($pfxUnprotectedBytes, $null, [Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
    $pfxProtectedBytes = $pfx.Export([Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $password)
    [IO.File]::WriteAllBytes($pfxPath, $pfxProtectedBytes)
    

    感谢 his blog post 中的 Brendon Coombes。

    【讨论】:

    • 仅供参考,下载的 PFX 没有密码。这意味着在其他服务中重新上传回 Azure 时通常无法使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-17
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 2018-12-29
    相关资源
    最近更新 更多