从Azure应用程序网关检索/恢复证书pfx

问题描述

我想检索/下载上传到我们的应用程序网关上的原始pfx证书。

到目前为止,我已经在PowerShell中完成以下操作:

$appGw = Get-AzApplicationGateway -Name "appgatewayname" -ResourceGroupName "appgatewayresourcegroup"

$certs = Get-AzApplicationGatewaySslCertificate -ApplicationGateway $appGw

$certBase64 = $certs[0].PublicCertData
$certBytes = [System.Convert]::FromBase64String($certBase64)

[io.file]::WriteallBytes("C:\directory\newcert.pfx",$certBytes)

但是,它似乎不是有效的证书,尤其是当我尝试将其上传到我们的keyvault时。

有人熟悉吗,这甚至可能吗?我应该使用Data属性而不是PublicCertData吗?

解决方法

.pfx文件上载到应用程序网关侦听器后,无法对其进行检索。我已经检查过Azure resource explorer,Azure没有提供API来检索它。而且我还与Azure产品团队进行了双重检查。

尽管似乎我们可以使用aq = airquality aq$date = as.Date(paste("2020",aq$Month,aq$Day,sep = "-")) library(ggplot2) ggplot(aq,aes(x = date,y = Ozone)) + geom_point() + scale_x_date(date_labels = "%b") PS命令​​来获取证书,但实际上,它仅向您提供PublicCertData,而没有.pfx文件的PrivateCertData。我也进行了测试,Data属性的值为空。

因此,如果要将.pfx文件上传到Azure KV,恐怕唯一的方法是直接将原始pfx证书直接上传到Azure KV。