Skip to content

Automation

Everything the app does is in the command line, SSLense.Cli, which runs in an elevated terminal.

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://..." ]
}
  • exitCode is the process exit code; errorCode is the first SSL code in the errors, or null.
  • data holds the result for status, list-sites, renew, health, history, cleanup list and version, and is null for 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.
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

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.

Terminal window
# On the old server
$env:SSLENSE_CONFIG_PASSWORD = [System.Net.NetworkCredential]::new('', (Read-Host -AsSecureString -Prompt Password)).Password
SSLense.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_PASSWORD
SSLense.Cli config import --file D:\move\settings.json --yes
SSLense.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 in SSLENSE_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. --certificates writes a CSV file for bulk issue, so they can be issued again on the new server.
  • Before importing, the current settings are saved as config.before-import-<time>.json in the data folder. Restart the SSLense service after an import.

The runbook for moving to another server has every step.

A script module over the command line, installed with SSLense:

Terminal window
Import-Module 'C:\Program Files\SSLense\cli\PowerShell\SSLense'
Get-SslenseCertificate
Invoke-SslenseRenewal -Site "Shop" -WhatIf
Get-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

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-Sslense returns the result with Succeeded, ExitCode and ErrorCode, and throws only with -ThrowOnError:

    Terminal window
    Invoke-Sslense renew --site "Shop" -ThrowOnError
  • Test-SslenseHealth returns the findings and never throws for a failed check. Each finding has Name, Status (Pass, Warning or Fail), Message and Fix:

    Terminal window
    $failed = Test-SslenseHealth | Where-Object Status -eq 'Fail'
    if ($failed) { $failed | Format-Table Name, Message, Fix; exit 1 }