Skip to content

Commit 4082211

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 NVIDIA#3195
1 parent 6701c82 commit 4082211

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
@@ -416,8 +416,14 @@ jobs:
416416
$redist = Join-Path $env:RUNNER_TEMP "vc_redist.x64.exe"
417417
Invoke-WebRequest -Uri "https://aka.ms/vs/17/release/vc_redist.x64.exe" -OutFile $redist
418418
$signature = Get-AuthenticodeSignature $redist
419-
if ($signature.Status -ne "Valid" -or $signature.SignerCertificate.Subject -notmatch "O=Microsoft Corporation") {
420-
throw "VC++ runtime is not validly signed by Microsoft: $($signature.Status)"
419+
if ($signature.Status -ne "Valid") { throw "VC++ runtime signature is not valid: $($signature.Status)" }
420+
# Compare the parsed organization (OID 2.5.4.10); a substring match on Subject also accepts
421+
# e.g. "O=Microsoft Corporation Services Ltd" or a CN containing "O=Microsoft Corporation".
422+
$org = @($signature.SignerCertificate.SubjectName.EnumerateRelativeDistinguishedNames() |
423+
Where-Object { $_.GetSingleElementType().Value -eq "2.5.4.10" } |
424+
ForEach-Object { $_.GetSingleElementValue() })
425+
if ($org.Count -ne 1 -or $org[0] -cne "Microsoft Corporation") {
426+
throw "VC++ runtime is not signed by Microsoft Corporation: O=$($org -join '|')"
421427
}
422428
$process = Start-Process $redist -ArgumentList "/install", "/quiet", "/norestart" -Wait -PassThru
423429
if ($process.ExitCode -notin 0, 1638, 3010) { throw "VC++ runtime installer failed: $($process.ExitCode)" }

0 commit comments

Comments
 (0)