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

Added ability to import certificates of other types than PKCS12/PFX #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ function Get-TargetResource
[parameter()]
[ValidateSet('Present','Absent')]
[string]
$Ensure = 'Present'
$Ensure = 'Present',
[parameter()]
[ValidateSet('PKCS12','PKCS7','X509')]
[string]
$Format = 'PKCS12'
)

#Needs to return a hashtable that returns the current
Expand Down Expand Up @@ -70,15 +74,27 @@ function Set-TargetResource
[parameter()]
[ValidateSet('Present','Absent')]
[string]
$Ensure = 'Present'
$Ensure = 'Present',
[parameter()]
[ValidateSet('PKCS12','PKCS7','X509')]
[string]
$Format = 'PKCS12'
)

$CertificateBaseLocation = "cert:\$Location\$Store"

if ($Ensure -like 'Present')
{
Write-Verbose "Adding $path to $CertificateBaseLocation."
Import-PfxCertificate -CertStoreLocation $CertificateBaseLocation -FilePath $Path

if ($Format -eq 'PKCS12')
{
Import-PfxCertificate -CertStoreLocation $CertificateBaseLocation -FilePath $Path
}
else
{
Import-Certificate -CertStoreLocation $CertificateBaseLocation -FilePath $Path
}
}
else
{
Expand Down Expand Up @@ -110,7 +126,11 @@ function Test-TargetResource
[parameter()]
[ValidateSet('Present','Absent')]
[string]
$Ensure = 'Present'
$Ensure = 'Present',
[parameter()]
[ValidateSet('PKCS12','PKCS7','X509')]
[string]
$Format = 'PKCS12'
)

$IsValid = $false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class StackExchange_CertificateStore : OMI_BaseResource
[write,ValueMap{"LocalMachine", "CurrentUser"},Values{"LocalMachine", "CurrentUser"}] string Location;
[write] string Store;
[write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure;
[write,ValueMap{"PKCS12", "PKCS7", "X509"},Values{"PKCS12", "PKCS7", "X509"}] string Format;
};


Expand Down