-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9,809 changed files
with
29,369 additions
and
2,107,592 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter()] | ||
[String] | ||
$Path | ||
) | ||
|
||
|
||
function FindSignTool { | ||
$SignTool = "signtool.exe" | ||
if (Get-Command $SignTool -ErrorAction SilentlyContinue) { | ||
return $SignTool | ||
} | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x64\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x86\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
$sdkVers = "10.0.22000.0", "10.0.20348.0", "10.0.19041.0", "10.0.17763.0" | ||
Foreach ($ver in $sdkVers) | ||
{ | ||
$SignTool = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\${ver}\x64\signtool.exe" | ||
if (Test-Path -Path $SignTool -PathType Leaf) { | ||
return $SignTool | ||
} | ||
} | ||
"signtool.exe not found" | ||
Exit 1 | ||
} | ||
|
||
function SignEsptool { | ||
param( | ||
[Parameter()] | ||
[String] | ||
$Path | ||
) | ||
|
||
$SignTool = FindSignTool | ||
"Using: $SignTool" | ||
$CertificateFile = [system.io.path]::GetTempPath() + "certificate.pfx" | ||
|
||
if ($null -eq $env:CERTIFICATE) { | ||
"CERTIFICATE variable not set, unable to sign the file" | ||
Exit 1 | ||
} | ||
|
||
if ("" -eq $env:CERTIFICATE) { | ||
"CERTIFICATE variable is empty, unable to sign the file" | ||
Exit 1 | ||
} | ||
|
||
$SignParameters = @("sign", "/tr", 'http://timestamp.digicert.com', "/td", "SHA256", "/f", $CertificateFile, "/fd", "SHA256") | ||
if ($env:CERTIFICATE_PASSWORD) { | ||
"CERTIFICATE_PASSWORD detected, using the password" | ||
$SignParameters += "/p" | ||
$SignParameters += $env:CERTIFICATE_PASSWORD | ||
} | ||
$SignParameters += $Path | ||
|
||
[byte[]]$CertificateBytes = [convert]::FromBase64String($env:CERTIFICATE) | ||
[IO.File]::WriteAllBytes($CertificateFile, $CertificateBytes) | ||
|
||
&$SignTool $SignParameters | ||
|
||
if (0 -eq $LASTEXITCODE) { | ||
Remove-Item $CertificateFile | ||
} else { | ||
Remove-Item $CertificateFile | ||
"Signing failed" | ||
Exit 1 | ||
} | ||
|
||
} | ||
|
||
SignEsptool ${Path} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.