如何在 AzureKeyValut 中手动续订证书

How do you manually renew a certificate in AzureKeyValut

我们有一个不受 Azure KeyVault 支持的 CA。我们已经使用 KeyVault 创建了证书和 CSR,并将它们成功提交给 CA 并导入了签名证书。我们现在有一些证书早于我们使用 KeyVault 的日期,需要续订。我们的安全团队已获得 CA 颁发的新签名证书。但是当我们导入原始的签名证书和私钥(pfx 格式)然后尝试导入新的签名证书时,它失败并显示 "Pending Certificate not found"。将这些证书放入 KeyVault 的正确顺序是什么。

Azure Key Vault 证书是一个受版本控制的对象。当您创建新证书时,您正在创建一个新版本。每个版本的证书在概念上都由两部分组成 - 一个非对称密钥和一个将非对称密钥与身份联系起来的 blob。

当您需要使用自己的 CA 时,AKV 会生成一个非对称密钥和 returns CSR 给用户。然后用户使用 CSR 获取证书。对于每个版本的证书都是如此。

如果您当前的版本即将到期,您需要创建一个新版本。您需要按照与创建第一个版本时相同的步骤进行操作。您可以选择在创建新版本时使用相同的非对称密钥。

所以取消上面的评论我能够让它工作。

#Password for the pfx file of the original cert
$password = ConvertTo-SecureString -String '<UPDATETHIS>' -AsPlainText -Force

#import the orginal cert with private key
Import-AzureKeyVaultCertificate -VaultName 'VaultName' -Name 'Certname' -FilePath 'PATHTOPFXFILE' -Password $password

#set the policy to allow key reuse if the CA will create a new signed cert from the existing CSR
Set-AzureKeyVaultCertificatePolicy -VaultName 'VaultName' -Name 'Certname' -ReuseKeyOnRenewal $true

#create a cert policy object from the existing cert
$certpolicy = Get-AzureKeyVaultCertificatePolicy -VaultName 'VaultName' -Name 'Certname'

#create a pending cert operation, you can pull a new CSR from this if need be
$certificateOperation = Add-AzureKeyVaultCertificate -VaultName 'VaultName' -Name 'Certname' -CertificatePolicy $certpolicy 

#import the new signed cert into KeyVault for issuing
Import-AzureKeyVaultCertificate -VaultName 'VaultName' -Name 'Certname' -FilePath 'PATHTONEWSIGNEDCERTINCRT'