Skip to content

Commit 2a4b082

Browse files
committed
Fixes cert plugin CertStore enforcement
1 parent 38f0aa0 commit 2a4b082

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

config/director/Invoke-IcingaCheckCertificate.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

config/director/Plugins_Bundle.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

config/icinga/Invoke-IcingaCheckCertificate.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object CheckCommand "Invoke-IcingaCheckCertificate" {
6363
order = 100
6464
}
6565
"-CertStore" = {
66-
description = "Used to specify which CertStore to check. Valid choices are '*', 'LocalMachine', 'CurrentUser'"
66+
description = "Used to specify which CertStore to check. Valid choices are 'None', '*', 'LocalMachine', 'CurrentUser'. Use 'None' if you do not want to check the certificate store (Default)"
6767
value = "$IcingaCheckCertificate_String_CertStore$"
6868
order = 5
6969
}

config/icinga/Plugins_Bundle.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ object CheckCommand "Invoke-IcingaCheckCertificate" {
157157
order = 100
158158
}
159159
"-CertStore" = {
160-
description = "Used to specify which CertStore to check. Valid choices are '*', 'LocalMachine', 'CurrentUser'"
160+
description = "Used to specify which CertStore to check. Valid choices are 'None', '*', 'LocalMachine', 'CurrentUser'. Use 'None' if you do not want to check the certificate store (Default)"
161161
value = "$IcingaCheckCertificate_String_CertStore$"
162162
order = 5
163163
}

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1414
## Bugfixes
1515

1616
* [#246](https://github.com/Icinga/icinga-powershell-plugins/pull/246) Fixes wrong `UNKNOWN` on `Invoke-IcingaCheckService` while using service display name with the `-Service` argument instead of the service name
17+
* [#261](https://github.com/Icinga/icinga-powershell-plugins/issues/261) Fixes `Invoke-IcingaCheckCertificate` which always included the CertStore because no option to not check the certificate store was available
1718
* [#262](https://github.com/Icinga/icinga-powershell-plugins/pull/262) Fixes method NULL exception on empty EventLog entries for `Invoke-IcingaCheckEventLog`
1819

1920
## Enhancements

doc/plugins/02-Invoke-IcingaCheckCertificate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ No special permissions required.
2222
| CriticalStart | Object | false | | Used to specify a date. The start date of the certificate has to be past the date specified, otherwise the check results in critical. Use carefully. Use format like: 'yyyy-MM-dd' |
2323
| WarningEnd | Object | false | 30d: | Used to specify a Warning range for the end date of an certificate. In this case a string. Allowed units include: ms, s, m, h, d, w, M, y |
2424
| CriticalEnd | Object | false | 10d: | Used to specify a Critical range for the end date of an certificate. In this case a string. Allowed units include: ms, s, m, h, d, w, M, y |
25-
| CertStore | String | false | * | Used to specify which CertStore to check. Valid choices are '*', 'LocalMachine', 'CurrentUser' |
25+
| CertStore | String | false | None | Used to specify which CertStore to check. Valid choices are 'None', '*', 'LocalMachine', 'CurrentUser'. Use 'None' if you do not want to check the certificate store (Default) |
2626
| CertThumbprint | Array | false | | Used to specify an array of Thumbprints, which are used to determine what certificate to check, within the CertStore. |
2727
| CertSubject | Array | false | | Used to specify an array of Subjects, which are used to determine what certificate to check, within the CertStore. |
2828
| ExcludePattern | Array | false | | Used to specify an array of exclusions, tested against Subject, Subject Alternative Name and Issuer. |

plugins/Invoke-IcingaCheckCertificate.psm1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
Allowed units include: ms, s, m, h, d, w, M, y
5353
5454
.PARAMETER CertStore
55-
Used to specify which CertStore to check. Valid choices are '*', 'LocalMachine', 'CurrentUser'
55+
Used to specify which CertStore to check. Valid choices are 'None', '*', 'LocalMachine', 'CurrentUser'.
56+
Use 'None' if you do not want to check the certificate store (Default)
5657
5758
.PARAMETER CertThumbprint
5859
Used to specify an array of Thumbprints, which are used to determine what certificate to check, within the CertStore.
@@ -103,8 +104,8 @@ function Invoke-IcingaCheckCertificate()
103104
$WarningEnd = '30d:',
104105
$CriticalEnd = '10d:',
105106
#CertStore-Related Param
106-
[ValidateSet('*', 'LocalMachine', 'CurrentUser')]
107-
[string]$CertStore = '*',
107+
[ValidateSet('None', '*', 'LocalMachine', 'CurrentUser')]
108+
[string]$CertStore = 'None',
108109
[array]$CertThumbprint = $null,
109110
[array]$CertSubject = $null,
110111
[array]$ExcludePattern = $null,

provider/certificate/Icinga_ProviderCertificate.psm1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ function Get-IcingaCertificateData()
22
{
33
param(
44
#CertStore-Related Param
5-
[ValidateSet('*', 'LocalMachine', 'CurrentUser')]
6-
[string]$CertStore = '*',
5+
[ValidateSet('None', '*', 'LocalMachine', 'CurrentUser')]
6+
[string]$CertStore = 'None',
77
[array]$CertThumbprint = $null,
88
[array]$CertSubject = $null,
99
[array]$ExcludePattern = $null,
@@ -77,15 +77,20 @@ function Get-IcingaCertStoreCertificates()
7777
{
7878
param (
7979
#CertStore-Related Param
80-
[ValidateSet('*', 'LocalMachine', 'CurrentUser')]
81-
[string]$CertStore = '*',
80+
[ValidateSet('None', '*', 'LocalMachine', 'CurrentUser')]
81+
[string]$CertStore = 'None',
8282
[array]$CertThumbprint = @(),
8383
[array]$CertSubject = @(),
8484
[array]$ExcludePattern = @(),
8585
$CertStorePath = '*'
8686
);
8787

8888
$CertStoreArray = @();
89+
90+
if ($CertStore -eq 'None') {
91+
return $CertStoreArray;
92+
}
93+
8994
$CertStorePath = [string]::Format('Cert:\{0}\{1}', $CertStore, $CertStorePath);
9095
$CertStoreCerts = Get-ChildItem -Path $CertStorePath -Recurse;
9196

0 commit comments

Comments
 (0)