Share via


更新應用程式閘道憑證

如果您為應用程式閘道設定了 TLS/SSL 加密,則到了某個時間點就必須更新憑證。

憑證的存放位置可能有兩個:儲存在 Azure Key Vault 中的憑證,或上傳至應用程式閘道的憑證。

Azure Key Vault 中的憑證

應用程式閘道設定為使用 Key Vault 憑證之後,其執行個體會從 Key Vault 擷取憑證,並安裝在本機以執行 TLS 終止。 執行個體每隔四小時輪詢一次 Key Vault,以擷取更新版的憑證 (若有)。 如果找到更新的憑證,系統會自動輪替目前與 HTTPS 接聽程式相關聯的 TLS/SSL 憑證。

提示

應用程式閘道只要發生變更,就會強制檢查 Key Vault,以查看是否有任何新版本憑證, 其中包括 (但不限於) 前端 IP 設定、接聽程式、規則、後端集區、資源標籤等變更。 一旦找到更新的憑證,就會立即出示新的憑證。

應用程式閘道使用 Key Vault 中的祕密識別碼來參考憑證。 針對 Azure PowerShell、Azure CLI 或 Azure Resource Manager,強烈建議您使用未指定版本的祕密識別碼。 這樣一來,如果 Key Vault 中有較新的版本,應用程式閘道便會自動輪換憑證。 https://myvault.vault.azure.net/secrets/mysecret/ 是沒有版本的祕密 URI 範例。

應用程式閘道上的憑證

應用程式閘道支援憑證上傳,且不需設定 Azure Key Vault。 若要更新上傳的憑證,請按照下列步驟在 Azure 入口網站、Azure PowerShell 或 Azure CLI 上操作。

Azure 入口網站

若要從入口網站更新接聽程式憑證,請瀏覽至您的應用程式閘道接聽程式。 選取含有需更新憑證的接聽程式,然後按一下 [更新或編輯選取的憑證]

Renew certificate

上傳新的 PFX 憑證並為其命名,輸入密碼,然後選取 [儲存]

Azure PowerShell

注意

建議您使用 Azure Az PowerShell 模組來與 Azure 互動。 請參閱安裝 Azure PowerShell 以開始使用。 若要了解如何移轉至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 移轉至 Az

若要使用 Azure PowerShell 更新您的憑證,請使用下列指令碼:

$appgw = Get-AzApplicationGateway `
  -ResourceGroupName <ResourceGroup> `
  -Name <AppGatewayName>

$password = ConvertTo-SecureString `
  -String "<password>" `
  -Force `
  -AsPlainText

set-AzApplicationGatewaySSLCertificate -Name <oldcertname> `
-ApplicationGateway $appgw -CertificateFile <newcertPath> -Password $password

Set-AzApplicationGateway -ApplicationGateway $appgw

Azure CLI

az network application-gateway ssl-cert update \
  -n "<CertName>" \
  --gateway-name "<AppGatewayName>" \
  -g "ResourceGroupName>" \
  --cert-file <PathToCerFile> \
  --cert-password "<password>"

下一步

若要了解如何使用 Azure 應用程式閘道設定 TLS 卸載,請參閱設定 TLS 卸載 (機器翻譯)。