ConfirmACMERenewalReadiness - RIT-ITS/CertifiCat-PS GitHub Wiki

Synopsis

Determines the readiness of a certificate to be renewed / replaced via the ACME server.

Syntax

Confirm-ACMERenewalReadiness  [-DomainName <String>] 
    [-RenewalMethod (PA/IIS/Directory)] [-RenewalDirectory <String>] 
    [-BindingPorts <String[]>] [-RenewalThreshold <Int>] [-debugEnabled]
    [-debugLogDirectory <string>] [-debugMode <string>]

Description

Queries for certificates in a variety of manners in order to determine if a new renewal order should be placed. Certificates that are found that expire 14 or more days in the future are determined to be "not ready" for renewal.

This function is primarily called as part of the Initialize-NewACMECertificate function, but can also be called directly in cases where an administrator wishes to only verify certificate expiry.

When this command is run directly, output is returned informationally; when the command is run as part of the Initialize-NewACMECertificate function, the result can (depending on configuration) block the new ACME certificate from being requested.

⚠️ Warning: Certain parameter combinations cannot be run on versions of PowerShell above 6 at this time. For more information, see the PowerShell Requirements section in the System Requirements page.

If the function detects that it is being used in a PowerShell 7+ console, it will suspend, and output a command that can be run in a legacy PowerShell console instead. See the Parameters list below for affected parameters and parameter values (generically, this applies to anything related to IIS or bindings).

Examples

Example 1: Identify Via Posh-ACME Working Directory

📄 Note: This is the default behavior when no specific RenewalMethod is specified

Confirm-ACMERenewalReadiness -DomainName web.example.com

This command will use the Posh-ACME working directory to locate an active, non-expired certificate whose subject contains the domain name value specifed.

Example 2: Identify Via IIS Bindings (All Ports)

Confirm-ACMERenewalReadiness -DomainName web.example.com -RenewalMethod IIS

This command will query all HTTPS bindings in IIS and alert if any of the associated certificates (whose subject contains the domain name value specifed) are active and ineligible for renewal.

Example 3: Identify Via IIS Bindings (Specific Ports)

Confirm-ACMERenewalReadiness -DomainName web.example.com -RenewalMethod IIS -BindingPorts 443, 8081

This command will query the bindings in IIS associated with the specified port(s) and alert if any of the associated certificates (whose subject contains the domain name value specifed) are active and ineligible for renewal.

Example 4: Identify Via Local Directory

Confirm-ACMERenewalReadiness -DomainName web.example.com -RenewalMethod Directory -RenewalDirectory c:\myCerts

This command will recursively query the directory specified, for any public key (*.cer) file and alert if any of the associated certificates (whose subject contains the domain name value specifed, and whose issuer contains 'incommon') are active and ineligible for renewal.

Parameters

-DomainName

The primary domain name associated with the certificate (e.g. in the Subject field).

Type: String
Position: 1 / Named
Default Value:  False
Required: True

-RenewalMethod

The mechanism to use to search for the existing certificates.

Type: String
Position: Named
ValidateSet: PA, IIS, Directory
Default Value:  PA
Required: False

⚠️ Warning: The "IIS" RenewalMethod cannot be run on versions of PowerShell above 6 at this time. For more information, see the PowerShell Requirements section in the System Requirements page.

If the function detects this parameter value being used in a PowerShell 7+ console, it will suspend, and output a command that can be run in a legacy PowerShell console instead.

-RenewalDirectory

When the RenewalMethod is "Directory," this specifies the directory in which to recursively look for certificates issued by InCommon with the subject containing the main domain.

Type: String
Position: Named
Default Value:  c:\its\certs\posh-acme
Required: False

-BindingPorts

When the RenewalMethod is "IIS," this optionally allows the function to look for certificates only associated with the provided port(s).

Type: String[]
Position: Named
Default Value:  False
Required: False

-RenewalThreshold

Specifies the number of days prior to the expiration of the current certificate needed before a request for a new certificate will be sent.

Type: Int
Position: Named
Default Value:  False
Required: False

-debugEnabled

This switch must be present to cause the function in question to output the contents of the object to a file or event log

Type: Switch
Position: Named
Required: False

-debugLogDirectory

Specifies where the CertifiCat-PS debug logs are written, when the debugMode option is EVT or Both.

Type: String
Position: Named
Required: False

-debugMode

Controls where the CertifiCat-PS debug informaiton is written: EVT (the windows event log), File (a text file on disk), or Both (a text file on disk and the Windows Event Log)

Type: String
Position: Named
Required: False
Default Value: EVT
ValidateSet: EVT, File, Both

Outputs

Returns a custom PowerShell object with properties about the function and the account that was set up. The object has the following properties:

Property Details
FunctionName Name of the function that was run
RunningPSVersion The version of the PowerShell console used to run the function
PS5Command A full string containing the commands needed to run the same command in PowerShell 5
FunctionArguments A list of the arguments passed to the function
FunctionSuccess True/False indicating if the function succeeded. When false, this typically indicates a larger issue (e.g. no admin rights, etc)
Errors A string containing details about any errors that were encountered
Bindings If the RenewalMethod is IIS, this will populate with an array of Web Binding objects that can be further analyzed. See Get-WebBinding.
Certificates Depending on the RenewalMethod chosen, this will be an array of either PoshACME.PACertificate objects (if the RenewalMethod = PA), or System.Security.Cryptography.X509Certificates.X509Certificate2 objects if the RenewalMethod is IIS or Directory. These objects can be further analyzed as needed
ReadyForRenewal A True/False indicating whether or not the certificate issued to the main domain should be renewed or not
RenewalThreshold The value provided as the minimum number of days required before expiration for a new certificate to be issued
debugEnabled Boolean indicating whether debug logging was enabled
debugLogDirectory String indicating the location of the debug log file, if file logging mode is enabled
debugMode String indicating the logging mode (i.e. EVT, File, or Both)

Related Links

⚠️ **GitHub.com Fallback** ⚠️