[英]Retrieving SSL certificate from Azure key vault to Azure app service
我在 Azure 密鑰庫中有一個 SSL 證書。 我需要通過 powershell 將此證書安裝到 Azure 應用服務。
Regarding the issue, we can download the SSL certificate from Azure key vault as pfx file, then use the pfx file to configure SSL for Azure web app
詳細步驟如下。
Connect-AzAccount
$cert=Get-AzKeyVaultSecret -VaultName "your key vault name" -Name ""
$password="Password0123!"
$certBytes = [System.Convert]::FromBase64String($cert.SecretValueText)
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$certCollection.Import($certBytes,$null,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$protectedCertificateBytes = $certCollection.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $password)
$pfxPath = "E:\mycert.pfx"
[System.IO.File]::WriteAllBytes($pfxPath, $protectedCertificateBytes)
New-AzWebAppSSLBinding -WebAppName $webappname -ResourceGroupName $webappname -Name $fqdn `
-CertificateFilePath $pfxPath -CertificatePassword $pfxPassword -SslState SniEnabled
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.