Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in PSPKI version check because of which New-SelfsignedCertifi… #31

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions Scripts/ServiceFabricRPHelpers/ServiceFabricRPHelpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,11 @@ if($CreateSelfSignedCertificate)

Write-Host "Creating new self signed certificate at $NewPfxFilePath"

## Changes to PSPKI version 3.5.2 New-SelfSignedCertificate replaced by New-SelfSignedCertificateEx
## Changes to PSPKI version 3.2.5 New-SelfSignedCertificate replaced by New-SelfSignedCertificateEx
$PspkiVersion = (Get-Module PSPKI).Version
if($PSPKIVersion.Major -ieq 3 -And $PspkiVersion.Minor -ieq 2 -And $PspkiVersion.Build -ieq 5) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice type here, PSPKIVersion is used instead of PspkiVersion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - when PSPKI latest version is used (3.2.6) - this condition returns false, thus New-SelfsignedCertificate is used instead of New-SelfsignedCertificateEx. Which is a big problem since Service Fabric services fail (with 'failed to read private key from certificate') to start when using a cert that was created via New-SelfsignedCertificate.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thankyou @aviade

$MinPspkiVersion= New-Object System.Version("3.2.5.0")

if($PspkiVersion -ge $MinPspkiVersion) {
New-SelfsignedCertificateEx -Subject "CN=$DnsName" -EKU "Server Authentication", "Client authentication" -KeyUsage "KeyEncipherment, DigitalSignature" -Path $NewPfxFilePath -Password $securePassword -Exportable
}
else {
Expand Down