forked from OCram85/PSCredentialStore
Publish version 1.0.x (#45)
## About ## Content (Micro Commits) * fixes #38 * fixes #44 * Implement precise lookup hierarchy (fixes #43) * align pester test with #43 logic * split cert functions * use new cert functions for save an lookup * fix pester tests * [wip] * fix var name ref * fix exports * fix cert store location for windows shared mode * fix mandatory params * fix accidentially removed code block * add basic cert pester pests * remove old docs * update cbh blocks * update cbh blocks * update docs * move .net wrapper forpfx files * do not export .net wrapper functions * update docs * rename tests * fix private functions location * - fixes #44: FTP connection * add link to reference * add format files * add preview version shield * update markdown help files (platyps) * add emoji images in captions * fix typos * fix typos * fix typo * prepare version numbers
This commit is contained in:
@ -25,11 +25,9 @@ function Get-CredentialStore {
|
||||
$CSContent = Get-CredentialStore -Path "C:\TMP\mystore.json"
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Get-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
- File Name : Get-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
@ -45,7 +43,7 @@ function Get-CredentialStore {
|
||||
[switch]$Shared
|
||||
)
|
||||
|
||||
begin {}
|
||||
begin { }
|
||||
|
||||
process {
|
||||
# Set the CredentialStore for private, shared or custom mode.
|
||||
@ -83,6 +81,6 @@ function Get-CredentialStore {
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,15 @@ function New-CredentialStore {
|
||||
.PARAMETER Force
|
||||
Use this switch to reset an existing store. The complete content will be wiped.
|
||||
|
||||
.PARAMETER SkipPFXCertCreation
|
||||
You can skip the pfx certificate creation process. This makes sense if you have a previously created cert or want to
|
||||
import a cert in cross-platform environments.
|
||||
|
||||
.Parameter UseCertStore
|
||||
Instead of using a plain pfx file beside your CredentialStore file you can import it into the user or machine
|
||||
certificate store. In this case the system itself secures the cert and you don't hat to set custom NTFS
|
||||
permissions so secure your shared certificate.
|
||||
|
||||
.INPUTS
|
||||
[None]
|
||||
|
||||
@ -42,11 +51,10 @@ function New-CredentialStore {
|
||||
# Creates a new shared CredentialStore in the given location.
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : New-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
- File Name : New-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
@ -100,7 +108,7 @@ function New-CredentialStore {
|
||||
$ErrorParams = @{
|
||||
ErrorAction = 'Stop'
|
||||
Exception = [System.IO.InvalidDataException]::new(
|
||||
'Your provided path does not conain the required file extension .json !'
|
||||
'Your provided path does not contain the required file extension .json !'
|
||||
)
|
||||
}
|
||||
Write-Error @ErrorParams
|
||||
@ -141,7 +149,7 @@ function New-CredentialStore {
|
||||
OrganizationalUnitName = $PSCmdlet.ParameterSetName
|
||||
CommonName = 'PSCredentialStore'
|
||||
}
|
||||
$CRTAttribute = New-CRTAttribute @CRTParams
|
||||
$CRTAttribute = New-CSCertAttribute @CRTParams
|
||||
|
||||
# If we are working with a ne shared store we have to create the location first.
|
||||
# Otherwise openssl fails with unknown path
|
||||
@ -171,7 +179,7 @@ function New-CredentialStore {
|
||||
}
|
||||
|
||||
try {
|
||||
New-PfxCertificate @PfxParams
|
||||
New-CSCertificate @PfxParams
|
||||
}
|
||||
catch {
|
||||
$_.Exception.Message | Write-Error
|
||||
@ -202,17 +210,6 @@ function New-CredentialStore {
|
||||
Thumbprint = $null
|
||||
Type = $null
|
||||
}
|
||||
if (! $SkipPFXCertCreation.IsPresent) {
|
||||
$ObjProperties.Thumbprint = $FreshCert.Thumbprint
|
||||
|
||||
if (!$UseCertStore.IsPresent) {
|
||||
$ObjProperties.PfxCertificate = $PfxParams.CertName
|
||||
}
|
||||
else {
|
||||
Write-Verbose 'Importing new PFX certificate file...'
|
||||
Import-CSCertificate -Path $PfxParams.CertName -StoreName My -StoreLocation CurrentUser
|
||||
}
|
||||
}
|
||||
|
||||
if ($PSCmdlet.ParameterSetName -eq "Shared") {
|
||||
$ObjProperties.Type = "Shared"
|
||||
@ -221,6 +218,20 @@ function New-CredentialStore {
|
||||
$ObjProperties.Type = "Private"
|
||||
}
|
||||
|
||||
if (! $SkipPFXCertCreation.IsPresent) {
|
||||
$ObjProperties.Thumbprint = $FreshCert.Thumbprint
|
||||
|
||||
if ($UseCertStore.IsPresent) {
|
||||
Write-Verbose 'Importing new PFX certificate file...'
|
||||
Import-CSCertificate -Type $ObjProperties.Type -Path $PfxParams.CertName
|
||||
}
|
||||
else {
|
||||
$ObjProperties.PfxCertificate = $PfxParams.CertName
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$CredentialStoreObj = [PSCustomObject]$ObjProperties
|
||||
try {
|
||||
$JSON = ConvertTo-Json -InputObject $CredentialStoreObj -ErrorAction Stop
|
||||
|
@ -14,12 +14,14 @@ function Test-CredentialStore {
|
||||
Switch to shared mode with this param. This enforces the command to work with a shared CredentialStore which
|
||||
can be decrypted across systems.
|
||||
|
||||
.EXAMPLE
|
||||
Test-CredentialStore -eq $true
|
||||
|
||||
.NOTES
|
||||
```
|
||||
File Name : Test-CredentialStore.ps1
|
||||
Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
Requires :
|
||||
```
|
||||
- File Name : Test-CredentialStore.ps1
|
||||
- Author : Marco Blessing - marco.blessing@googlemail.com
|
||||
- Requires :
|
||||
|
||||
.LINK
|
||||
https://github.com/OCram85/PSCredentialStore
|
||||
#>
|
||||
@ -60,6 +62,6 @@ function Test-CredentialStore {
|
||||
}
|
||||
}
|
||||
|
||||
end {}
|
||||
end { }
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user