Skip to content

Commit 9e1c0e1

Browse files
committed
CI: match the vc_redist signer organization exactly
The substring check on SignerCertificate.Subject also accepted an organization such as "Microsoft Corporation Services Ltd" or a CN that embeds "O=Microsoft Corporation". Compare the parsed organization attribute (OID 2.5.4.10) instead, and check the signature status first so an unsigned file gets a clear error. Refs #3195
1 parent 7978973 commit 9e1c0e1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎.github/workflows/test-wheel-windows.yml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,14 @@ jobs:
429429
$redist = Join-Path $env:RUNNER_TEMP "vc_redist.x64.exe"
430430
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile $redist
431431
$signature = Get-AuthenticodeSignature $redist
432-
if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "O=Microsoft Corporation") {
433-
throw "VC++ runtime is not validly signed by Microsoft: $($signature.Status)"
432+
if ($signature.Status -ne "Valid") { throw "VC++ runtime signature is not valid: $($signature.Status)" }
433+
# Compare the parsed organization (OID 2.5.4.10); a substring match on Subject also accepts
434+
# e.g. "O=Microsoft Corporation Services Ltd" or a CN containing "O=Microsoft Corporation".
435+
$org = @($signature.SignerCertificate.SubjectName.EnumerateRelativeDistinguishedNames() |
436+
Where-Object { $_.GetSingleElementType().Value -eq "2.5.4.10" } |
437+
ForEach-Object { $_.GetSingleElementValue() })
438+
if ($org.Count -ne 1 -or $org[0] -cne "Microsoft Corporation") {
439+
throw "VC++ runtime is not signed by Microsoft Corporation: O=$($org -join '|')"
434440
}
435441
$process = Start-Process $redist -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru
436442
if ($process.ExitCode -notin 0, 1638, 3010) { throw "VC++ runtime installer failed: $($process.ExitCode)" }

0 commit comments

Comments
 (0)