共用方式為


維護 Exchange Server OAuth 憑證

一般資訊

本文件說明輪替 Exchange Server 驗證憑證的必要步驟,而不會中斷 Exchange 服務,以及目前的驗證憑證到期之前。

提示

您也可以使用 MonitorExchangeAuthCertificate 腳本。 它會執行自動輪替 OAuth 憑證的必要步驟。 如果 OAuth 憑證已過期,它也可以協助您取代該憑證。

Microsoft Exchange Server 會使用驗證設定和驗證憑證,以使用 Open Authorization (OAuth) 通訊協定標準來啟用伺服器對伺服器驗證。 您可以在下列文章中找到詳細信息:規劃與 SharePoint 的 Exchange 整合和 商務用 Skype

數個 Exchange Server 安全性功能也會使用驗證憑證。

在第一部 Exchange 伺服器安裝期間,安裝程式會產生具有易記名稱 Microsoft Exchange Server Auth Certificate的自我簽署憑證,然後新增至新的驗證組態。 此憑證會自動復寫到 Exchange 組織中的所有前端伺服器。 Exchange 憑證 Servicelet 會執行複寫,這是程式的一 MSExchangeServiceHost 部分。 如果您將更多伺服器新增至 Exchange 組織,Servicelet 會負責將憑證複寫至已新增至組織的所有 Exchange 伺服器。

設定為目前驗證憑證的憑證,可以藉由執行下列 PowerShell (進行查詢,必須在 Exchange 管理命令介面中執行) 查詢:

(Get-AuthConfig).CurrentCertificateThumbprint | Get-ExchangeCertificate | Format-List Subject, Thumbprint, NotAfter, NotBefore

如果呼叫失敗並出現下列警告,表示伺服器上缺少目前的驗證憑證。

A special Rpc error occurs on server <Servername>: The certificate with thumbprint <AuthCertificateThumbprint> was not found.

Follow the instructions mentioned in the "What are the steps to follow if the current certificate has already expired or is missing" section to fix.

設定為下一個驗證憑證的憑證可以依照下列方式查詢:

(Get-AuthConfig).NextCertificateThumbprint | Get-ExchangeCertificate | Format-List Subject, Thumbprint, NotAfter, NotBefore

如果呼叫失敗,並出現與目前驗證憑證相同的警告,表示伺服器上未設定或遺失下一個驗證憑證。

如果目前的驗證憑證即將到期,請遵循「如何輪替 Exchange Server 驗證憑證」中所述的指示。

如果目前的憑證已過期或遺失,要遵循哪些步驟?

在此情況下,必須立即以新的驗證憑證取代舊的驗證憑證。 請遵循下列支援文章的解決方式一節中所述的指示:如果 OAuth 憑證已過期,則無法登入 Outlook 網頁版 或 EAC Exchange Server

如何輪替 Exchange Server 驗證憑證

請務必在有效驗證憑證到期之前,以新的驗證憑證取代該憑證。 這麼做可確保順利轉換至新的憑證,而不會中斷 Exchange 服務。 您可以遵循下列步驟來準備和暫存新的驗證憑證。

重要事項

請確定您已安裝最新的 Exchange Server 累積更新 (CU) ,因為它包含會影響對應 Exchange 功能的修正程式。

  1. 執行下列命令來產生新的驗證憑證:

    $newAuthCertificate = New-ExchangeCertificate -KeySize 2048 -PrivateKeyExportable $true -SubjectName "cn=Microsoft Exchange Server Auth Certificate" -FriendlyName "Microsoft Exchange Server Auth Certificate" -DomainName @()
    
  2. 請勿在類型 'N' (覆寫現有的預設 SMTP 憑證,然後按 enter) :

    Confirm
    Overwrite the existing default SMTP certificate?
    
    Current certificate: '<DefaultSMTPCertificateThumbprint>' (expires 12/30/2027 2:39:08 PM)
    Replace it with certificate: '<NewCertificateThumbprint>' (expires 1/5/2028 9:04:48 AM)
    [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): N
    
  3. 將驗證憑證設定為最早在 49 小時內成為新的使用中憑證:

    Set-AuthConfig -NewCertificateThumbprint $newAuthCertificate.Thumbprint -NewCertificateEffectiveDate (Get-Date).AddHours(49)
    

注意事項

根據您的 Exchange 組織大小,新的驗證憑證可能需要一些時間才能部署到所有 Exchange 伺服器。 我們的建議是在新產生的驗證憑證生效前至少規劃 48 小時。

Exchange AuthAdmin Servicelet 也是程式的 MSExchangeServiceHost 一部分,負責最終的驗證憑證發佈程式。 如果服務重新啟動, MSExchangeServiceHost 就會立即執行 Servicelet。 之後會每隔 12 小時執行一次,如果偵測到 NewCertificateEffectiveDate 已到達 ,則會發佈新的驗證憑證,使其成為新的使用中憑證。

您可以執行下列 PowerShell Cmdlet 來查詢 AuthAdmin Servicelet 的最後一個運行時間:

[xml]$xml = Get-ExchangeDiagnosticInfo -Process "Microsoft.Exchange.ServiceHost"
$xml.Diagnostics.Components.AnchorApplication.AnchorServiceComponents.CacheScheduler.lastRunTime

AuthAdmin Servicelet 的每個執行都會記錄到下列目錄: <ExchangeInstallPath>\Logging\AuthAdminLogs

當驗證憑證的輪替成功完成時,Servicelet 會產生新的事件記錄專案:

Log Name:      Application
Source:        MSExchange AuthAdmin
Date:          12/29/2022 5:56:13 AM
Event ID:      2014
Task Category: General
Level:         Information
Keywords:      Classic
User:          N/A
Description:   The current signing certificate for Exchange has been updated to certificate with thumbprint <NewExchangeCertificateThumbprint>.

注意事項

若要確保 AuthAdmin Servicelet 可以啟動,當您的 Exchange Server 安裝在子域且系統信箱位於根域時,您必須啟用 AuthAdminReadSession。 否則,AuthAdmin Servicelet 將無法啟動。

Set-OrganizationConfig -EnableAuthAdminReadSession:$true

常見問題集

問題: 更換驗證憑證之後,是否需要重新執行混合式設定精靈 (HCW) ?

回答: 是,強烈建議您在使用中的驗證憑證被取代之後,執行混合式設定精靈 (HCW) 。

問題: 如果在不同 Active Directory (AD) 網站的 Exchange 伺服器上遺失新的驗證憑證,該怎麼辦?

回答: 您可以使用 Export-ExchangeCertificate Cmdlet 導出憑證,並透過其他 AD 網站伺服器上的 Import-ExchangeCertificate 匯入憑證。 憑證服務會負責複寫至位於AD網站內的其餘Exchange伺服器。