Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve/recover cert pfx from Azure Application Gateway

I want to retrieve/download the original pfx certificate that was uploaded onto our Application Gateway.

So far I have done the following in 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)

However, it doesn't seem to be a valid certificate, especially when I try to upload it onto our KeyVault.

Is anyone familiar, and is this even possible? Should I use the Data property instead of the PublicCertData?

like image 959
AnimaSola Avatar asked Nov 15 '25 23:11

AnimaSola


1 Answers

.pfx file can't be retrieved after you uploaded it to an application gateway listener. I have checked Azure resource explorer, there is no API provided by Azure to retrieve it. And I also double-checked with the Azure product team.

Though seems we can use Get-AzApplicationGatewaySslCertificate PS command to get certs, but actually, it provides you with PublicCertData only, there is no PrivateCertData of .pfx file. I also have tested on my side, the value of Data property is empty.

So if you want to upload this .pfx file to Azure KV, I am afraid the only way is uploading the original pfx certificate to Azure KV directly.

like image 66
Stanley Gong Avatar answered Nov 17 '25 18:11

Stanley Gong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!