How to set FriendlyName to Pfx certificate and upload certificate to webapp using powershell

400 views Asked by At

I have pfx certificate. I need to add FriendlyName to Pfx certificate and then add certificate to Webapp using azure cloud shell.

Using following script, you can set friendlyName,

$cert= Get-PfxCertificate -FilePath "XYZ\XYZC.pfx" | SELECT *   
$cert.FriendlyName = "XXXTest"

But then this $cert cannot be used for uploading certificate with friendlyName. Following script is for adding certificate to Webapp.

New-AzWebAppSSLBinding -ResourceGroupName "resourceName" -WebAppName "webAppName" -CertificateFilePath "XYZ\XYZC.pfx" -CertificatePassword "XXXX" -Name "webAppName"

Is there a way to set friendlyName before uploading to webapp. Appreciate for help.

1

There are 1 answers

2
Jahnavi On

To set friendly Name before uploading to webapp:

As -FriendlyName flag is existed in the New-SelfSignedCertificate. You can add a friendly Name to the certificate as it is being created itself.

$params = @{
    DnsName = 'www.xxxx.com'
    CertStoreLocation = 'Cert:\path\Mydir'
    FriendlyName = 'jahtest'
}
$cert =New-SelfSignedCertificate @params
Export-PfxCertificate -Cert $cert -FilePath "C:\Desktop\mynewcert.cer" -Password (ConvertTo-SecureString -String "xxxxxx" -Force -AsPlainText)
$certdata= Get-PfxCertificate -FilePath "C:\Users\v-majahnavi\Desktop\mynewcert.cer" | SELECT *
$certdata.FriendlyName = "jahtest"

enter image description here

enter image description here

New-AzWebAppSSLBinding -CertificateFilePath xxxx -CertificatePassword xxxxx -Name 'xxxx.azurewebsites.net' -ResourceGroupName '<ResourceGroup>' -SslState Disabled -WebAppName '<WebApp>'

Uploaded successfully:

enter image description here