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?