-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes certificate handling to provide systemwide compatibility
- Loading branch information
1 parent
174063e
commit bd5beff
Showing
15 changed files
with
183 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+124 KB
doc/images/04_knowledgebase/IWKB000018/04_set_permission_and_apply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,65 @@ | ||
function Get-IcingaForWindowsCertificate() | ||
{ | ||
[string]$CertificateFolder = Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'certificate'; | ||
[string]$CertificateFile = Join-Path -Path $CertificateFolder -ChildPath 'icingaforwindows.pfx'; | ||
[string]$CertThumbprint = $null; | ||
[PSCustomObject]$CertFilter = $null; | ||
[Security.Cryptography.X509Certificates.X509Certificate2]$Certificate = $null; | ||
|
||
if (-Not (Test-Path $CertificateFile)) { | ||
return $null; | ||
if ($Global:Icinga.Public.ContainsKey('SSL')) { | ||
$CertThumbprint = $Global:Icinga.Public.SSL.CertThumbprint; | ||
$CertFilter = $Global:Icinga.Public.SSL.CertFilter; | ||
} | ||
|
||
return ([Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile($CertificateFile)); | ||
if ([string]::IsNullOrEmpty($CertThumbprint) -eq $FALSE -Or $null -ne $CertFilter) { | ||
[hashtable]$FilterArgs = @{ | ||
'-Recurse' = $TRUE; | ||
'-Path' = 'cert:\LocalMachine\*'; | ||
} | ||
|
||
if ([string]::IsNullOrEmpty($CertThumbprint) -eq $FALSE) { | ||
$FilterArgs.Add('-Include', $CertThumbprint); | ||
} | ||
|
||
[array]$Certificates = Get-ChildItem @FilterArgs; | ||
[DateTime]$CurrentTime = [DateTime]::Now; | ||
|
||
foreach ($cert in $Certificates) { | ||
if ((Test-PSCustomObjectMember -PSObject $CertFilter -Name 'Subject') -And [string]::IsNullOrEmpty($CertFilter.Subject) -eq $FALSE) { | ||
if ($cert.Subject.ToLower() -NotLike $CertFilter.Subject.ToLower()) { | ||
continue; | ||
} | ||
} | ||
|
||
if ((Test-PSCustomObjectMember -PSObject $CertFilter -Name 'Issuer') -And [string]::IsNullOrEmpty($CertFilter.Issuer) -eq $FALSE) { | ||
if ($cert.Issuer.ToLower() -NotLike $CertFilter.Issuer.ToLower()) { | ||
continue; | ||
} | ||
} | ||
|
||
# Certificate expiration date | ||
if ($cert.NotAfter -lt $CurrentTime) { | ||
continue; | ||
} | ||
|
||
# Certificate start date | ||
if ($cert.NotBefore -gt $CurrentTime) { | ||
continue; | ||
} | ||
|
||
$Certificate = $cert; | ||
break; | ||
} | ||
} else { | ||
[string]$CertificateFolder = Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath 'certificate'; | ||
[string]$CertificateFile = Join-Path -Path $CertificateFolder -ChildPath 'icingaforwindows.pfx'; | ||
|
||
if (-Not (Test-Path $CertificateFile)) { | ||
return $null; | ||
} | ||
|
||
$Certificate = ( | ||
New-Object Security.Cryptography.X509Certificates.X509Certificate2 $CertificateFile, '', ([System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet) | ||
); | ||
} | ||
|
||
return $Certificate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters