Renew the Exchange certificate

When the Exchange certificate expires, many things break at once: Outlook, mobile devices, mail flow with TLS. The renewal itself takes ten minutes if you keep the order and don’t forget any place where the old certificate is still configured.

Check what you have

Get-ExchangeCertificate | Format-List Thumbprint,Subject,CertificateDomains,Services,NotAfter

Note the thumbprint of the expiring certificate and which services (IIS, SMTP, IMAP, POP) it has. Don’t confuse it with the Microsoft Exchange Server Auth Certificate: that is the internal OAuth certificate and is renewed separately.

Create the request

The easiest way is to renew the existing certificate with the same names. The request file must be written to a share (UNC path):

Get-ExchangeCertificate -Thumbprint <OLD_THUMBPRINT> |
  New-ExchangeCertificate -GenerateRequest -RequestFile \\ex01\c$\temp\exchange.req -PrivateKeyExportable $true

For a completely new certificate, specify the names yourself. Common are the name for OWA and Outlook plus autodiscover:

New-ExchangeCertificate -GenerateRequest -SubjectName "CN=mail.example.com" `
  -DomainName mail.example.com,autodiscover.example.com -KeySize 2048 `
  -PrivateKeyExportable $true -RequestFile \\ex01\c$\temp\exchange.req

Submit the .req file to the CA. You need -PrivateKeyExportable to copy the certificate to further Exchange servers later.

Import the certificate

# CA response for the pending request
Import-ExchangeCertificate -Server ex01 -FileData ([System.IO.File]::ReadAllBytes('\\ex01\c$\temp\mail.cer'))

# or a finished PFX (e.g. for the second server)
Import-ExchangeCertificate -Server ex02 -FileData ([System.IO.File]::ReadAllBytes('\\ex01\c$\temp\mail.pfx')) `
  -Password (Read-Host -AsSecureString "PFX password") -PrivateKeyExportable $true

If the intermediate part is missing, the certificate converter completes the chain and creates a complete PFX.

Assign services

Enable-ExchangeCertificate -Server ex01 -Thumbprint <NEW_THUMBPRINT> -Services IIS,SMTP

Exchange asks whether to overwrite the default SMTP certificate. Answering No keeps the self-signed internal certificate for transport between Exchange servers, which is right in most environments. For STARTTLS on port 25 Exchange uses the new certificate if one of its names matches the FQDN of the receive connector or it is set there with TlsCertificateName (see below). Add -Services IMAP,POP if needed.

Connectors and hybrid

If a certificate is pinned in a connector (TlsCertificateName), the entry must point to the new certificate. This mainly affects hybrid environments with Exchange Online:

Get-SendConnector | Format-List Name,TlsCertificateName
Get-ReceiveConnector | Format-List Identity,TlsCertificateName

$c = Get-ExchangeCertificate -Thumbprint <NEW_THUMBPRINT>
$name = "<I>$($c.Issuer)<S>$($c.Subject)"
Set-SendConnector "Outbound to Office 365 - <GUID>" -TlsCertificateName $name
Set-ReceiveConnector "EX01\Default Frontend EX01" -TlsCertificateName $name

In hybrid environments, run the Hybrid Configuration Wizard again afterwards.

Remove the old certificate and test

Remove-ExchangeCertificate -Server ex01 -Thumbprint <OLD_THUMBPRINT>

If the old certificate cannot be removed, it is still referenced somewhere; the error message names the connector. Then test from outside: port 443 with the SSL check, port 25 with the mail server check. With several servers behind a load balancer, check each server individually.

FAQ

Do I need to restart IIS?

Normally not. If OWA still shows the old certificate after the switch, an iisreset at a quiet moment helps.

Do I need autodiscover in the certificate?

Yes, if Outlook queries autodiscover.example.com over HTTPS. If you resolve Autodiscover only via an SRV record or internally via SCP, you can do without.

Can I do this in the Exchange admin center?

Yes, under Servers → Certificates there are wizards for request, import and services. Connectors and hybrid are adjusted in the shell, though.

Sources and documentation