Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add signature verification
  • Loading branch information
hoyosjs committed Aug 22, 2022
commit 754b0576c9acbd5b6ad5943a14bcc3515aae26c0
26 changes: 26 additions & 0 deletions eng/pipelines/coreclr/templates/sign-diagnostic-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,29 @@ steps:
DOTNET_MULTILEVEL_LOOKUP: 0
DOTNET_ROOT: '$(Agent.TempDirectory)/dotnet'
DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR: '$(Agent.TempDirectory)/dotnet'

- powershell: |
$filesToSign = $(Get-ChildItem -Recurse ${{ parameters.basePath }} -Include mscordaccore*.dll, mscordbi*.dll)
foreach ($file in $filesToSign) {
$signingCert = $(Get-AuthenticodeSignature $file).SignerCertificate
if ($signingCert -eq $null)
{
throw "File $file does not contain a signature."
}

if ($signingCert.Subject -ne "CN=.NET DAC, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" `
-or $signingCert.Issuer -ne "CN=Microsoft Code Signing PCA 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US")
{
throw "File $file not in expected trust chain."
}

$certEKU = $signingCert.Extensions.Where({ $_.Oid.FriendlyName -eq "Enhanced Key Usage" }) | Select -First 1

if ($certEKU.EnhancedKeyUsages.Where({ $_.Value -eq "1.3.6.1.4.1.311.84.4.1" }).Count -ne 1)
{
throw "Signature for $file does not contain expected EKU."
}

Write-Host "$file is correctly signed."
}
displayName: Validate diagnostic signatures