簡體   English   中英

將 SSL 證書從 Azure 密鑰保管庫檢索到 Azure 應用服務

[英]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

詳細步驟如下。

  1. 從 Azure 密鑰庫下載 SSL 證書 請注意,在運行以下命令之前,請為密鑰保管庫中的帳戶配置訪問策略
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)
  1. 配置SSl
New-AzWebAppSSLBinding -WebAppName $webappname -ResourceGroupName $webappname -Name $fqdn `
-CertificateFilePath $pfxPath -CertificatePassword $pfxPassword -SslState SniEnabled

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM