diff --git a/CHANGELOG.md b/CHANGELOG.md index 8391cf3f3..9732d82ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md) ## [Unreleased] +- xWebSite + - Added logic to select certificate with private key. ([issue #578](https://github.com/dsccommunity/xWebAdministration/issues/578)) + - Added logic to select certificate with most available time ([issue #578](https://github.com/dsccommunity/xWebAdministration/issues/578)) + ### Added - xWebAdminstration diff --git a/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 b/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 index ea3e5b285..c36720c44 100644 --- a/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 +++ b/source/DSCResources/MSFT_xWebSite/MSFT_xWebSite.psm1 @@ -1473,7 +1473,7 @@ function ConvertTo-WebBinding if ($FindCertificateSplat) { $FindCertificateSplat.Add('Store',$CertificateStoreName) - $Certificate = Find-Certificate @FindCertificateSplat | Select-Object -First 1 + $Certificate = Find-Certificate @FindCertificateSplat | Where-Object {$_.HasPrivateKey -eq $true} | Sort-Object -Property NotAfter -Descending | Select-Object -First 1 if ($Certificate) { $certificateHash = $Certificate.Thumbprint