Skip to content

Commit 52b4c10

Browse files
committed
Check Authenticode signature on setup
Check that an Authenticode signature on setup is present, valid and made by the expected key.
1 parent e67b1f4 commit 52b4c10

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Parameters
2929
| add-to-path | true | Whether to add Cygwin's `/bin` directory to the system `PATH`
3030
| allow-test-packages | false | Consider package versions marked test for installation
3131
| check-hash | true | Whether to check the hash of the downloaded Cygwin installer.
32+
| check-installer-sig | true | Whether to check the Authenticode signature of the downloaded Cygwin installer.
3233
| work-vol | D: | Volume on which to store setup and packages, and install Cygwin.
3334

3435
Line endings
@@ -100,7 +101,9 @@ Mirrors and signatures
100101
----------------------
101102

102103
You probably don't need to change the setting for `site`, and you shouldn't
103-
change `check-sig` unless you're very confident it's appropriate and necessary.
104+
change `check-installer-sig` or `check-sig` unless you're very confident it's
105+
appropriate and necessary.
106+
104107
These options are very unlikely to be useful except in some very isolated
105108
circumstances, such as using the [Cygwin Time
106109
Machine](http://www.crouchingtigerhiddenfruitbat.org/Cygwin/timemachine.html).

action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ inputs:
3737
description: Check the hash of the installer
3838
required: false
3939
default: 'true'
40+
check-installer-sig:
41+
description: Check the Autheticode signature of the installer
42+
required: false
43+
default: 'true'
4044
work-vol:
4145
description: Volume on which to store setup and packages, and install Cygwin
4246
required: false
@@ -102,6 +106,15 @@ runs:
102106
throw "The downloaded setup has a zero length!"
103107
}
104108
109+
$signature = Get-AuthenticodeSignature -FilePath $setupExe
110+
echo "Signature status: $($signature.Status) fingerprint: $($signature.SignerCertificate.GetCertHashString("SHA256"))"
111+
# TBD: this should check against a list of fingerprints for valid certs we have used
112+
if (!$signature.Status -ne 'Valid' -or $signature.SignerCertificate.GetCertHashString("SHA256") -ne '2ce11da3a675a9d631e06a28ddfd6f730b9cc6989b43bd30ad7cc79d219cf2bd') {
113+
if ('${{ inputs.check-installer-sig }}' -eq 'true') {
114+
throw "Invalid CodeSign signature on the downloaded setup!"
115+
}
116+
}
117+
105118
if ('${{ inputs.check-hash }}' -eq 'true') {
106119
$hashFile = "$vol\sha512.sum"
107120
Invoke-WebRequest-With-Retry https://cygwin.com/sha512.sum $hashFile

0 commit comments

Comments
 (0)