azure - 如何检索生成的 Azure Key Vault 证书的 PFX 密码?
问题描述
Azure Key Vault 允许你直接在 GUI 中生成证书。之后,您可以将这些证书下载为 pfx 文件。
这些 pfx 文件是否受密码保护?我正在尝试在某处使用此证书,它不会让我在没有密码的情况下继续操作。
解决方案
使用 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 在他的博客文章中。
推荐阅读
- python-3.x - 填充列内的间隙并按数字拆分列
- javascript - 反应构建不执行 index.htm 中的脚本
- c# - 闪烁编辑器多语法突出显示
- php - 从文本框中拆分逗号分隔的输入并将其转换为数组
- html - 如何在浏览器页眉/页脚消失时处理移动视口更改?
- php - 如何在 php 中将 url (http://\/\test) 解码为 (http://test)?
- python - Tensorflow通过张量迭代
- php - 从数字中删除小数点
- javascript - 问题 js Body sprite 未在 Firefox 中显示
- installation - `conda install pytorch` 使用`import torch` 导致“非法指令”