azure - 如何检索生成的 Azure Key Vault 证书的 PFX 密码?

标签 azure azure-keyvault

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

这些 pfx 文件是否受密码保护?我正尝试在某处使用此证书,但如果没有密码,我将无法继续操作。

Azure Key Vault Create a certificate

最佳答案

使用以下适用于 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)

归功于 Brendon Coombes his blog post .

关于azure - 如何检索生成的 Azure Key Vault 证书的 PFX 密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66330093/

相关文章:

azure - 部署后清理包文件夹

azure - 部署包含 key 保管库中存储的证书的 ARM 模板时出错

azure 应用程序网关无法与 502 一起使用

c# - 有时调用 CompleteAsync 方法时,Azure 设备客户端会抛出 DeviceMessageLockLostException

c# - 如何使用 Azure Mgmt SDK Fluent 获取端点统计信息和危险端点列表

c# - Azure Key Vault 是否适合存储客户端应用程序上生成的加密 key ?

azure - 如何将 az keyvault Secret list -o table 输出存储在数组中? Azure CLI、Shell 脚本

azure - 从 Android 设备连接到本地主机并与之同步无法正常工作

azure - 如何从 Azure DevOps 管道将 secret 写入 azure key Vault?

azure-functions - 确认您的 Key Vault 的状态