From 91e37ea16c621cd8583509310ef885a336d311ab Mon Sep 17 00:00:00 2001 From: Tobias Deiminger Date: Mon, 10 May 2021 09:17:46 +0200 Subject: [PATCH] Fix loading certificate from .pfx file If you tried this Use-Icinga; Get-IcingaSSLCertForSocket -CertFile "C:/my/cert.pfx" the former code expanded like $FileType = Get-Item -Path "C:/my/cert.pfx"; if ("cert.pfx" -eq '.pfx') { ... not reached ... } and thus did not load the certificate file. Now use GetExtension instead of Get-Item to make the .pfx check work. --- lib/webserver/Get-IcingaSSLCertForSocket.psm1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/webserver/Get-IcingaSSLCertForSocket.psm1 b/lib/webserver/Get-IcingaSSLCertForSocket.psm1 index 8115c9d..760173b 100644 --- a/lib/webserver/Get-IcingaSSLCertForSocket.psm1 +++ b/lib/webserver/Get-IcingaSSLCertForSocket.psm1 @@ -10,8 +10,7 @@ function Get-IcingaSSLCertForSocket() # to get a proper certificate if ([string]::IsNullOrEmpty($CertFile) -eq $FALSE) { if ((Test-Path $CertFile)) { - $FileType = Get-Item -Path $CertFile; - if ($FileType -eq '.pfx') { + if ([IO.Path]::GetExtension($CertFile) -eq '.pfx') { return (New-Object Security.Cryptography.X509Certificates.X509Certificate2 $CertFile); } else { return ConvertTo-IcingaX509Certificate -CertFile $CertFile;