r/exchangeserver • u/Ill_Addendum_5419 • 13h ago
r/exchangeserver • u/Interesting-Pea-6558 • 4h ago
Article Exchange Certificate Swap PowerShell - Github
https://github.com/LoneRiderOH/exchange-cert-swap.git
I hope guys/girls this will make you job easier.
A single-file PowerShell WPF GUI for replacing the public IIS/SMTP certificate on on-premises Exchange Server 2016, 2019 and Subscription Edition mailbox servers, using a PFX file or a free certificate from Let's Encrypt, ZeroSSL, Google Trust Services, SSL.com or Actalis. It covers the whole process: inventory, validation, import, enable, verification and safe removal of the old certificate. Dry run is on by default.
Features
Free certificates (optional): requests a certificate from Let's Encrypt, ZeroSSL, Google Trust Services, SSL.com or Actalis using the Posh-ACME module, and passes the resulting PFX straight to validation. Proof of domain ownership, chosen per request:
- HTTP-01: the tool writes the challenge file into IIS on every selected server, so it works behind a load balancer. It checks that each server serves the file before the CA is asked to validate.
- DNS-01 manual: the tool shows the
_acme-challengeTXT records to create, then checks public DNS before continuing. Supports wildcards. - DNS-01 automatic via Cloudflare: built-in option for domains hosted on Cloudflare DNS. You paste a scoped API token, and the tool tests it, creates and removes the TXT records itself, and can remember the token, encrypted for your Windows user. It also detects when your names are on Cloudflare DNS.
- DNS-01 automatic via other DNS hosts: uses any of Posh-ACME's ~90 DNS provider plugins (Route 53, Azure DNS, GoDaddy and more).
- Inventory: lists every Exchange certificate on all selected mailbox servers and marks the Auth (OAuth) and internal transport certificates.
Validation before changes (read-only):
- the PFX contains a private key, is in its validity period and has the Server Authentication EKU
- the chain builds to a trusted root
- every
InternalUrl/ExternalUrlon the OWA, ECP, EWS, OAB, ActiveSync and MAPI virtual directories, plus the Autodiscover SCP, is covered by the certificate's SANs (wildcards are handled correctly) - lists Send and Receive connectors whose
TlsCertificateNamestill points to the old certificate
- Import to multiple servers: imports the same PFX on every selected server with
Import-ExchangeCertificate -FileData, so the tool doesn't need to be run on each server. - SMTP connectors: updates Send and Receive connectors whose
TlsCertificateNamepoints to the old certificate, such as the hybrid Outbound to Office 365 and Default Frontend connectors set by the HCW. It can also pin the new certificate on the Default Frontend connector (port 25), so internet senders get the public certificate on STARTTLS instead of the self-signed one. The connector FQDN is never changed, and rollback commands are logged. - Enable for IIS and SMTP: if
Enable-ExchangeCertificate -Forcereplaces the internal transport certificate, the tool restores the previous one unless you choose otherwise. - Verification on the network: opens a real TLS connection to each server on port 443 and compares the served thumbprint with the new certificate. It also checks SMTP port 25 with STARTTLS (for information only) and any extra endpoints you list, such as a load balancer or public name.
Safe removal of the old certificate: a certificate is removed only if: You confirm each removal.
- its server passed verification
- it is not the Auth or internal transport certificate
- it is no longer bound to IIS
- no connector points to it
- Dry run by default: every command is logged instead of being run. You turn Dry run off on purpose, and the header switches to red LIVE MODE.
- Full log: each run writes
logs\CertSwap_<timestamp>.lognext to the script. PFX passwords are never logged. - No private key is written to the machine that runs the tool: the PFX is opened with
EphemeralKeySet, so its key stays in memory. It never goes into a Windows key store or onto a smart card or hardware token. The key is installed only on the Exchange servers, throughImport-ExchangeCertificate.
r/exchangeserver • u/Amos54 • 10h ago
Question What do you use for automated certificate deployment in Exchange?
We operate in a hybid environment with 365, running Exhange SE on-prem. Now that public CA's have begun shortening the validity periods of their certs, which will eventually be down to 47 days by the time 2029 rolls around, we need something better than what we've been doing which is pretty much just manual renewal since it used to only be done once a year.
We've had Sectigo's cert manager product for a while and though I haven't actively used it much it wouldn't take me long to get more familiar with it. A colleague of mine whom I work closely with has used it more often so it wouldn't be an issue to work him to see what we can do. We've already automated specific named certs for different apps and websites using this product, primarily on IIS.
Here's what our current manual process looks like:
- Within the Exchange console, select the cert in use and select renew and step through the menu until it spits out a request file.
- Send request file, receive cert. Select the complete request option in Exchange console, and then have to ensure that it selects the new cert as the 'active' one to be using (it usually prompts for this overwriting action), and then also have to manually select associate the new cert with IIS on the Exchange server.
- I then run a Exchange shell command to update the TLS connectors with the new cert which I have to change the thumbprint for it to know which cert I'm talking about.
- Lastly once all of that is done I run through the HCW to select the new cert here.
I don't think I can remove any of these steps, but I'm sure I'm not the only one in this position. What are some of you doing for automated deployment?