-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cli#2160 from mbpreble/sign-windows-executables
Sign Windows .exes in a post-build hook
- Loading branch information
Showing
4 changed files
with
53 additions
and
1 deletion.
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
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,19 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
GITHUB_CERT_PASSWORD=$1 | ||
DESKTOP_CERT_TOKEN=$2 | ||
|
||
if [[ -z "$GITHUB_CERT_PASSWORD" || -z "$DESKTOP_CERT_TOKEN" ]]; then | ||
echo "skipping windows signing prep; cert password or token not found" | ||
exit 0 | ||
fi | ||
|
||
curl \ | ||
-H "Authorization: token $DESKTOP_CERT_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3.raw" \ | ||
--output windows-certificate.pfx \ | ||
https://api.github.com/repos/desktop/desktop-secrets/contents/windows-certificate.pfx | ||
|
||
openssl pkcs12 -in windows-certificate.pfx -nocerts -nodes -out private-key.pem -passin pass:${GITHUB_CERT_PASSWORD} | ||
openssl pkcs12 -in windows-certificate.pfx -nokeys -nodes -out certificate.pem -passin pass:${GITHUB_CERT_PASSWORD} |
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,26 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [[ ! -e certificate.pem || ! -e private-key.pem ]]; then | ||
echo "skipping windows signing; cert or key not found" | ||
exit 0 | ||
fi | ||
|
||
EXECUTABLE_PATH=$1 | ||
ARCH="386" | ||
|
||
if [[ $EXECUTABLE_PATH =~ "amd64" ]]; then | ||
ARCH="amd64" | ||
fi | ||
|
||
OUT_PATH=gh_signed-${ARCH}.exe | ||
|
||
osslsigncode sign \ | ||
-certs certificate.pem \ | ||
-key private-key.pem \ | ||
-n "GitHub CLI" \ | ||
-t http://timestamp.digicert.com \ | ||
-in $EXECUTABLE_PATH \ | ||
-out $OUT_PATH | ||
|
||
mv $OUT_PATH $EXECUTABLE_PATH |