Browse Source

Improve signtool path detection and password security

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 3 days ago
parent
commit
e7f2a80034
1 changed files with 18 additions and 9 deletions
  1. 18 9
      .github/workflows/windows.yml

+ 18 - 9
.github/workflows/windows.yml

@@ -140,25 +140,34 @@ jobs:
           [System.IO.File]::WriteAllBytes($certPath, $certBytes)
           [System.IO.File]::WriteAllBytes($certPath, $certBytes)
           
           
           try {
           try {
-            # Find signtool.exe
-            $signtool = Get-ChildItem "C:\Program Files (x86)\Windows Kits" -Recurse -Filter "signtool.exe" -ErrorAction SilentlyContinue |
-              Where-Object { $_.FullName -match "x64" } |
-              Select-Object -First 1
+            # Find signtool.exe - check multiple potential locations
+            $searchPaths = @(
+              "$env:ProgramFiles(x86)\Windows Kits",
+              "$env:ProgramFiles\Windows Kits"
+            )
+            
+            $signtool = $null
+            foreach ($searchPath in $searchPaths) {
+              if (Test-Path $searchPath) {
+                $signtool = Get-ChildItem $searchPath -Recurse -Filter "signtool.exe" -ErrorAction SilentlyContinue |
+                  Where-Object { $_.FullName -match "x64" } |
+                  Select-Object -First 1
+                if ($signtool) { break }
+              }
+            }
             
             
             if (-not $signtool) {
             if (-not $signtool) {
-              Write-Error "signtool.exe not found in Windows Kits directory"
+              Write-Error "signtool.exe not found in Windows Kits directories"
               exit 1
               exit 1
             }
             }
             
             
             Write-Host "Using signtool: $($signtool.FullName)"
             Write-Host "Using signtool: $($signtool.FullName)"
             
             
-            # Prepare signing arguments
-            $certPassword = "${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}"
-            
+            # Prepare signing arguments - pass password directly without intermediate variable
             $signArgs = @(
             $signArgs = @(
               "sign",
               "sign",
               "/f", $certPath,
               "/f", $certPath,
-              "/p", $certPassword,
+              "/p", "${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}",
               "/tr", "http://timestamp.digicert.com",
               "/tr", "http://timestamp.digicert.com",
               "/td", "SHA256",
               "/td", "SHA256",
               "/fd", "SHA256",
               "/fd", "SHA256",