Skip to content

Commit e38da14

Browse files
author
Bob Pokorny
committed
Updated PS scripts to get CSPs from registry not certutil.
1 parent bc07ae8 commit e38da14

3 files changed

Lines changed: 47 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Adding JEA Support for local PowerShell execution. This will allow for more secure execution of the extension when running in a local PowerShell Runspace. To utilize this feature, you will need to create a JEA endpoint on the target server and specify the endpoint name as a new parameter in the specific Cert Store definition. Refer to the README for more details.
55
* .NET6 assemblies are no longer supported.
66
* Fixed a problem when passing a bad CSP, the job was reporting successful, but did not actually add/bind the certificate.
7+
* Enhanced Crypto Service Provider (CSP) discovery and validation to work correctly on localized Windows installations. Customers running Traditional Chinese Windows (zh-TW / CP950) reported that certificate add jobs were failing with "Crypto Service Provider ... is either invalid or not found on this system." even when the requested CSP was installed. The root cause was that `Get-CryptoProviders` parsed `certutil -csplist` output and matched on the literal English label "Provider Name:", which is translated on non en-US Windows, causing the enumerated provider list to come back empty and every CSP name to fail validation. Provider enumeration now reads from the culture-invariant registry hive `HKLM:\SOFTWARE\Microsoft\Cryptography\Defaults\Provider` (with a code-page-safe `certutil` fallback for hardened systems where the registry hive is unavailable), and CSP name matching in `Validate-CryptoProvider` now uses ordinal, case-insensitive comparison so results are unaffected by the current thread culture (Turkish-I folding, full-/half-width character folding, etc.).
78

89
3.0.2
910

@@ -22,14 +23,14 @@
2223
* Fixed the SNI/SSL flag being returned during inventory, now returns extended SSL flags
2324
* Fixed the SNI/SSL flag when binding the certificate to allow for extended SSL flags
2425
* Added SSL Flag validation to make sure the bit flag is correct. These are the valid bit flags for the version of Windows:
25-
### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5):
26+
### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5)### Windows Server 2012 R2 / Windows 8.1 and earlier (IIS 8.5):
2627

2728

2829
* 0 No SNI
2930
* 1 Use SNI
3031
* 2 Use Centralized SSL certificate store.
3132

32-
### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0):
33+
### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0)### Windows Server 2016 (IIS 10.0):
3334

3435
* 0 No SNI
3536
* 1 Use SNI

IISU/PowerShell/Keyfactor.WinCert.Common/Private/Get-CryptoProviders.ps1

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
11
function Get-CryptoProviders {
2-
# Retrieves the list of available Crypto Service Providers using certutil
2+
# Retrieves the list of available Crypto Service Providers.
3+
#
4+
# Preferred source is the registry because CSP names are stored as
5+
# culture-invariant subkey names under
6+
# HKLM:\SOFTWARE\Microsoft\Cryptography\Defaults\Provider
7+
38
try {
4-
Write-Information "[VERBOSE] Retrieving Crypto Service Providers using certutil..."
5-
$certUtilOutput = certutil -csplist
6-
7-
# Parse the output to extract CSP names
9+
Write-Information "[VERBOSE] Retrieving Crypto Service Providers from registry..."
10+
11+
$regPath = 'HKLM:\SOFTWARE\Microsoft\Cryptography\Defaults\Provider'
812
$cspInfoList = @()
9-
foreach ($line in $certUtilOutput) {
10-
if ($line -match "Provider Name:") {
11-
$cspName = ($line -split ":")[1].Trim()
12-
$cspInfoList += $cspName
13+
14+
if (Test-Path -LiteralPath $regPath) {
15+
$cspInfoList = @(
16+
Get-ChildItem -LiteralPath $regPath -ErrorAction Stop |
17+
Select-Object -ExpandProperty PSChildName
18+
)
19+
}
20+
21+
if ($cspInfoList.Count -eq 0) {
22+
Write-Information "[VERBOSE] Registry enumeration returned no CSPs; falling back to certutil."
23+
24+
$prevOutEncoding = [Console]::OutputEncoding
25+
try {
26+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
27+
$certUtilOutput = & certutil.exe -csplist 2>&1
28+
} finally {
29+
[Console]::OutputEncoding = $prevOutEncoding
30+
}
31+
32+
# The "Provider Name:" label is localized, so match on the structural
33+
# shape of the line instead of the English text: an un-indented
34+
# "<label>: <value>" line whose value is not a numeric provider type
35+
# ("1 - PROV_RSA_FULL", etc.).
36+
foreach ($line in $certUtilOutput) {
37+
if ($line -match '^\S[^:]+:\s+(\S.+)$') {
38+
$value = $Matches[1].Trim()
39+
if ($value -notmatch '^\d+\s*-\s*\S') {
40+
$cspInfoList += $value
41+
}
42+
}
1343
}
1444
}
1545

1646
if ($cspInfoList.Count -eq 0) {
17-
throw "No Crypto Service Providers were found. Ensure certutil is functioning properly."
47+
throw "No Crypto Service Providers were found."
1848
}
1949

2050
Write-Information "[VERBOSE] Retrieved the following CSPs:"

0 commit comments

Comments
 (0)