Reputation: 2826
I am trying to install inspec in powershell and during the install I am receiving an error.
Cannot find type [Security.Cryptography.SHA256Cng]: verify that the assembly containing this type is loaded.
The current version of powershell is 7.
The install command being used is.
. { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -project inspec
It installs ok on the windows powershell version 5.1 but it doesn't on the downloaded and installed version of powershell 7.4.1
I have tried hashing something using sha256 and it works ok.
Upvotes: 0
Views: 52
Reputation: 59782
The issue is that SHA256Cng
Class only exists .NET Framework and PowerShell 7+ uses .NET, if you wanted to make it work, the function having a reference to that class is Get-SHA256Converter
and you could change it to this to make it compatible with both versions:
function Get-SHA256Converter {
if ($IsCoreCLR) {
return [System.Security.Cryptography.SHA256]::Create()
}
if ((Is-FIPS) -ge 1) {
return [Security.Cryptography.SHA256Cng]::new()
}
[Security.Cryptography.SHA256Managed]::new()
}
Upvotes: 0