Automation
Everything the app does is in the command line, SSLense.Cli, which runs in an elevated terminal.
JSON output
Section titled “JSON output”Add --json to any command, and it writes one JSON document instead of text:
{ "command": "renew", "exitCode": 1, "succeeded": false, "errorCode": "SSL3002", "data": [ { "siteName": "Shop", "attempted": true, "succeeded": false, "message": "..." } ], "output": [ "lines the command printed" ], "errors": [ "Error: SSL3002: ...", "More: https://..." ]}exitCodeis the process exit code;errorCodeis the first SSL code in the errors, ornull.dataholds the result forstatus,list-sites,renew,health,history,cleanup listandversion, and isnullfor other commands.- Properties use camelCase. New ones may be added in later versions; existing ones are not renamed.
- Commands that wait for someone to type, such as
issue --validation dns-manual, are not for--json.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success. For health, no check failed (warnings are allowed) |
| 1 | The command ran and failed, or found a problem; the error starts with an SSL code |
| 2 | The command line was not valid: an unknown command or option, or a missing or wrong value |
| 3 | The command must run as an administrator |
Settings export and import
Section titled “Settings export and import”config export writes this server's settings to a file, and config import puts them on another server: the default email, renewal and reminder settings, the maintenance window, certificate authorities, DNS providers and notifications.
# On the old server$env:SSLENSE_CONFIG_PASSWORD = [System.Net.NetworkCredential]::new('', (Read-Host -AsSecureString -Prompt Password)).PasswordSSLense.Cli config export --file D:\move\settings.json --include-secrets --certificates D:\move\certificates.csv# On the new server, with the same password in SSLENSE_CONFIG_PASSWORDSSLense.Cli config import --file D:\move\settings.json --yesSSLense.Cli bulk issue --file D:\move\certificates.csv --dry-run- Secrets (DNS tokens, notification passwords and URLs, EAB keys) are left out unless you use
--include-secrets, with a password inSSLENSE_CONFIG_PASSWORD. They are then encrypted with that password, and protected with DPAPI on the new server. The password is never accepted on the command line, so it stays out of shell history. - Certificates are not moved: private keys never leave the machine.
--certificateswrites a CSV file forbulk issue, so they can be issued again on the new server. - Before importing, the current settings are saved as
config.before-import-<time>.jsonin the data folder. Restart the SSLense service after an import.
The runbook for moving to another server has every step.
The PowerShell module
Section titled “The PowerShell module”A script module over the command line, installed with SSLense:
Import-Module 'C:\Program Files\SSLense\cli\PowerShell\SSLense'Get-SslenseCertificateInvoke-SslenseRenewal -Site "Shop" -WhatIfGet-SslenseHistory -Site "Shop"| Command | Does |
|---|---|
Get-SslenseCertificate |
The managed certificates |
Get-SslenseSite |
IIS sites and their bindings |
Get-SslenseHistory |
A certificate's timeline |
Test-SslenseHealth |
The health check: one finding per check |
Invoke-SslenseRenewal |
Renews one certificate or all due; supports -WhatIf |
Undo-SslenseCertificate |
Rolls back to the previous certificate; supports -WhatIf |
Export-SslenseConfig, Import-SslenseConfig |
Settings export and import |
Invoke-Sslense |
Any other CLI command, with its whole JSON result |
When something fails
Section titled “When something fails”Most commands throw when the CLI fails, with the SSL code in $Error[0].Exception.Data['ErrorCode']. Two do not, so check their result:
-
Invoke-Sslensereturns the result withSucceeded,ExitCodeandErrorCode, and throws only with-ThrowOnError:Terminal window Invoke-Sslense renew --site "Shop" -ThrowOnError -
Test-SslenseHealthreturns the findings and never throws for a failed check. Each finding hasName,Status(Pass,WarningorFail),MessageandFix:Terminal window $failed = Test-SslenseHealth | Where-Object Status -eq 'Fail'if ($failed) { $failed | Format-Table Name, Message, Fix; exit 1 }