This article covers manually implementing Let's Encrypt using Certify the Web and NOT using the automated SSL process available in SmarterMail. These other articles may be of help as well:
Here’s a brief on to implement Let’s Encrypt for a SmarterMail installation, from the certificate's enrollment to its automatic renewal:
Refer to the attached screenshot for a visual guide.
Note: If you've successfully followed the instructions above, you can ignore the subsequent steps related to the PowerShell export script. These are only provided as alternatives should you encounter issues with the main procedure.
Automating the Certificate Export from the Microsoft Certificate Store for SmarterMail
For secure SSL/TLS communications, SmarterMail requires a PFX or CER file to reference for port configurations, such as POP, IMAP, SMTP, and XMPP. When using Let’s Encrypt, the certificate must be pulled from the certificate store every 90 days as the certificate approaches its expiration.
PowerShell Script for Exporting the Certificate
Below is a PowerShell script that can be used to export the required certificate. This script creates a password-protected PFX file suitable for SmarterMail port configurations:
Get-ChildItem -Path 'Cert:\localmachine\My' | Where-Object { $_.hasPrivateKey } | Where-Object {$_.Subject -like "*mail.domain.com*"} | Foreach-Object {&certutil.exe @('-exportpfx', '-f', '-p', 'DesiredPassword',$_.Thumbprint, "c:\PathToCertificate\mail.domain.com.pfx")}
Please note: There are three elements in the script (italicized and bolded above) that you'll need to customize for your environment:
- mail.domain.com: The domain for which you are securing the communications.
- DesiredPassword: The password you wish to set for the PFX file.
- c:\PathToCertificate\mail.domain.com.pfx: The desired path and filename for the exported PFX file.
After adjusting these variables, save the script. For our example, we've saved it as C:\SmarterMail\Scripts\ExportCert.PS1.
Creating a Batch Script to Execute the PowerShell Script
To automate the execution, create a batch script with the following content:
Powershell.exe -executionpolicy remotesigned -File c:\SmarterMail\Scripts\ExportCert.ps1
Save this batch file as ExportCert.bat in C:\SmarterMail\Scripts.
Setting Up a Scheduled Task
To ensure the certificate is regularly exported:
- Create a Windows Scheduled Task to run the ExportCert.bat script daily.
- When setting up the task, make sure you choose the option to run the task regardless of whether a user is logged in or not.
- Ensure the task runs with the highest privileges to guarantee the private key is exported correctly from the certificate store.
After you've run this setup for the first time, you'll need to configure the SmarterMail ports to utilize the freshly exported certificate for SSL/TLS communications. For guidance on this, refer to our KB article on configuring SSL/TLS.