Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CertReq: Expired Certificate Validation #268

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
images - Fixes [Issue #262](https://github.com/dsccommunity/CertificateDsc/issues/262).
- Updated pipeline unit tests and integration tests to use Windows Server 2019 and
Windows Server 2022 images - Fixes [Issue #262](https://github.com/dsccommunity/CertificateDsc/issues/262).
- Adds logic to exclude certificates which have _already expired_ from being included in the array of
certificates returned from the certificate store, when building a certificate request to be submitted to the PKI.

### Fixed

Expand Down
5 changes: 3 additions & 2 deletions source/DSCResources/DSC_CertReq/DSC_CertReq.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,15 @@ function Set-TargetResource
$Subject = "CN=$Subject"
} # if

# If we should look for renewals, check for existing certs
# If we should look for renewals, check for existing, non-expired certs
if ($AutoRenew)
{
$certs = Get-ChildItem -Path Cert:\LocalMachine\My |
Where-Object -FilterScript {
$_.Subject -eq $Subject -and `
(Compare-CertificateIssuer -Issuer $_.Issuer -CARootName $CARootName) -and `
$_.NotAfter -lt (Get-Date).AddDays(30)
$_.NotAfter -gt (Get-Date) -and `
$_.NotAfter -lt (Get-Date).AddDays(30)
}

# If multiple certs have the same subject and were issued by the CA and are 30 days from expiration, return the newest
Expand Down
Loading