VxRail.API.Common using deprecated function CertificatePolicy which doesnt work in Powershell 7
- Dominant language
- PowerShell
- Stars
- 0
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
The VxRail.API.Common is using the deprecated "[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy" found on line 20, and no longer works when trying to use Powershell 7, either administrator or normal user. The module will import in Powershell 5.1
Reference:
https://learn.microsoft.com/en-us/dotnet/api/system.net.servicepointmanager.certificatepolicy?view=netframework-4.7.2
PowerShell 7.4.1
PS C:\Windows\System32> Import-Module VxRail.API
Import-Module: (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a using directive or an assembly reference?)
public class TrustAllCertsPolicy : ICertificatePolicy {
^
PS C:\Windows\System32> Import-Module VxRail.API.Certificate
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a
| using directive or an assembly reference?) public class TrustAllCertsPolicy : ICertificatePolicy {
| ^
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| Cannot add type. Compilation errors occurred.
New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20
Line |
20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded.
PS C:\Windows\System32> Import-Module VxRail.API.Chassis
PS C:\Windows\System32> Import-Module VxRail.API.Cluster
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a
| using directive or an assembly reference?) public class TrustAllCertsPolicy : ICertificatePolicy {
| ^
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| Cannot add type. Compilation errors occurred.
New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20
Line |
20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded.
PS C:\Windows\System32> Import-Module VxRail.API.disk
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| (3,40): error CS0246: The type or namespace name 'ICertificatePolicy' could not be found (are you missing a using directive or an assembly reference?) public class
| TrustAllCertsPolicy : ICertificatePolicy { ^
Add-Type: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:9
Line |
9 | add-type @"
| ~~~~~~~~~~~
| Cannot add type. Compilation errors occurred.
New-Object: C:\Program Files\WindowsPowerShell\Modules\VxRail.API.Common\1.0.0.0\VxRail.API.Common.ps1:20
Line |
20 | … vicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot find type [TrustAllCertsPolicy]: verify that the assembly containing this type is loaded.
PS C:\Windows\System32>
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with VxRail.API.Common.ps1 at lines 9 and 20, then reproduce the reported Import-Module failures under PowerShell 7.4.1 and compare them with PowerShell 5.1. Done means VxRail.API.Common and the dependent VxRail.API modules import without the reported compilation or missing-type errors in PowerShell 7.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100