devblackops / PasswordState

PowerShell module for interacting with ClickStudio's PasswordState password management application
Apache License 2.0
40 stars 14 forks source link

Added check to _SetCertPolicy.ps1 for PS Core support #8

Closed ephos closed 7 years ago

ephos commented 7 years ago

Addeded an if else check for against $PSVersiontable.PSEdition to check if the current edition of PowerShell is Core or Desktop. PowerShell Core / 6 will add $PSDefaultParameterValues for Invoke-RestMethod and Invoke-WebRequest to always use the "-SkipCertificateCheck" parameter. PowerShell 5.X and earlier will continue to use the ICertificatePolicy method.

Added a check to _SetCertPolicy.ps1 for the PowerShell edition.

Description

_SetCertPolicy.ps1 will check if $PSVersionTable.Edition is 'Core' or 'Desktop'. It will handle certificate validation accordingly. PowerShell Core/6 will use $PSDefaultParameterValue for Invoke-RestMethod and Invoke-WebRequest. PowerShell Desktop/5.x will continue to use the C# code calling ICertificatePolicy.

Related Issue

Related to issue #7

Motivation and Context

This solves the issue where the module was unable to import on PowerShell Core/6 by changing how a private function handles checking certificates.

How Has This Been Tested?

All existing tests were run prior to commit.

Screenshots (if appropriate):

Types of changes

Checklist:

devblackops commented 7 years ago

Looks good @ephos. Thanks!