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: Get-TargetResource will try to find incorrect certificate if X500 subject is used #210

Closed
p0shkar opened this issue Oct 12, 2019 · 0 comments

Comments

@p0shkar
Copy link
Contributor

p0shkar commented Oct 12, 2019

Details of the scenario you tried and the problem that is occurring

In Get-TargetResource the following code is used:

$cert = Get-Childitem -Path Cert:\LocalMachine\My |
    Where-Object -FilterScript {
        $_.Subject -eq "CN=$Subject" -and `
        (Compare-CertificateIssuer -Issuer $_.Issuer -CARootName $CARootName)
    }

If the subject contains the full X500 path, in Get-TargetResource this will result in it trying to find a Certificate with Subject "CN=CN=SomeSubject,O=Or,C=Other,S=etc".

Verbose logs showing the problem

Suggested solution to the issue

Use the same fix as in Test- and Set-TargetResource:

# If the Subject does not contain a full X500 path, construct just the CN
if (($Subject.split('=').count) -eq 1)
{
    $Subject = "CN=$Subject"
}

The DSC configuration that is used to reproduce the issue (as detailed as possible)

The operating system the target node is running

Version and build of PowerShell the target node is running

5.1

Version of the DSC module that was used ('dev' if using current dev branch)

dev

Registering this bug for tracking, this bug was discovered during work on PR #209 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant