Skip to content
This repository has been archived by the owner on May 15, 2018. It is now read-only.

Add Password parameter, and change Test-TargetResource to match the Subj... #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcraig88
Copy link

Add Password parameter, and change Test-TargetResource to match the Subject name, instead of looking for equal to.

This has been tested on Windows 2008R2 and 2012R2.

…ubject name, instead of looking for equal to
@mcraig88
Copy link
Author

Windows 2012 will use Import-PfxCertificate, Windows 2008 will use certutil.

@mcraig88 mcraig88 closed this Oct 21, 2014
@mcraig88 mcraig88 reopened this Oct 21, 2014
@dlwyatt
Copy link
Member

dlwyatt commented Oct 22, 2014

I don't think it's a good idea to have any kind of wildcard matching on a DSC resource's key property.

Adding support for PFX passwords is a good idea, but using a [string] for this is not secure. Off the top of my head, I don't remember if we can just stick a [securestring] argument in there and have itwork, or if DSC will only encrypt PSCredential parameters for you (with corresponding MSFT_Credential objects in the MOF file.) Will test that soon.

Write-Verbose "Removing $CertificateLocation."
dir $CertificateLocation | Remove-Item -Force -Confirm:$false
Write-Verbose "Removing $name from $CertificateBaseLocation."
gci $CertificateBaseLocation | ?{$_.Subject -match $name.Replace('*','')} | Remove-Item -Force -Confirm:$false
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to support matching a wildcard certificate, such as *.mysite.com.
Possibly a better method would be to match on a Thumbprint, instead of a certificate name. Thoughts?

@dlwyatt
Copy link
Member

dlwyatt commented Oct 22, 2014

You could use a wildcard certificate while still using the -eq operator in PowerShell. The * character would just be part of the certificate's subject.

I do agree that using a thumbprint might have been a better choice. The question now would be whether we should make a breaking change on the resource now to change its API, or just leave it as-is.

@mcraig88
Copy link
Author

Ok, I'll see what I can do here.

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

Successfully merging this pull request may close these issues.

2 participants