-
Notifications
You must be signed in to change notification settings - Fork 891
feat(windows): add product information to coder.exe #5055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,9 @@ jobs: | |
AC_APIKEY_ISSUER_ID: ${{ secrets.AC_APIKEY_ISSUER_ID }} | ||
AC_APIKEY_ID: ${{ secrets.AC_APIKEY_ID }} | ||
AC_APIKEY_FILE: /tmp/apple_apikey.p8 | ||
CODER_SIGN_WINDOWS: "0" | ||
AUTHENTICODE_CERTIFICATE_FILE: /tmp/windows_cert.pkcs12 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code signing certificates can be obtained via https://sectigo.com/ssl-certificates-tls/code-signing and will require organization validation (ie. a DUNS number and corresponding phone number that works) |
||
AUTHENTICODE_CERTIFICATE_PASSWORD_FILE: /tmp/windows_cert_password.txt | ||
|
||
- name: Delete Apple Developer certificate and API key | ||
run: rm -f /tmp/{apple_cert.p12,apple_cert_password.txt,apple_apikey.p8} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,8 @@ site/out/ | |
*.lock.hcl | ||
.terraform/ | ||
|
||
**/*.syso | ||
|
||
.vscode/*.log | ||
.vscode/launch.json | ||
**/*.swp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | ||
<assemblyIdentity | ||
type="win32" | ||
name="Coder.com.Coder" | ||
version="1.0.0.0" | ||
processorArchitecture="*"/> | ||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | ||
<security> | ||
<requestedPrivileges> | ||
<requestedExecutionLevel | ||
level="asInvoker" | ||
uiAccess="false"/> | ||
</requestedPrivileges> | ||
</security> | ||
</trustInfo> | ||
</assembly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"FixedFileInfo": | ||
{ | ||
"FileVersion": { | ||
"Major": 0, | ||
"Minor": 0, | ||
"Patch": 0, | ||
"Build": 0 | ||
}, | ||
"ProductVersion": { | ||
"Major": 0, | ||
"Minor": 0, | ||
"Patch": 0, | ||
"Build": 0 | ||
}, | ||
"FileFlagsMask": "3f", | ||
"FileFlags ": "00", | ||
"FileOS": "040004", | ||
"FileType": "01", | ||
"FileSubType": "00" | ||
}, | ||
"StringFileInfo": | ||
{ | ||
"Comments": "https://coder.com", | ||
"CompanyName": "Coder Technologies, Inc", | ||
"FileDescription": "Coder", | ||
"FileVersion": "", | ||
"InternalName": "coder", | ||
"LegalCopyright": "© Coder Technologies, Inc. All rights reserved.", | ||
"LegalTrademarks": "", | ||
"OriginalFilename": "coder.exe", | ||
"PrivateBuild": "", | ||
"ProductName": "Coder®", | ||
"ProductVersion": "", | ||
"SpecialBuild": "" | ||
}, | ||
"VarFileInfo": | ||
{ | ||
"Translation": { | ||
"LangID": "0409", | ||
"CharsetID": "04B0" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,11 @@ os="${GOOS:-linux}" | |
arch="${GOARCH:-amd64}" | ||
slim="${CODER_SLIM_BUILD:-0}" | ||
sign_darwin="${CODER_SIGN_DARWIN:-0}" | ||
sign_windows="${CODER_SIGN_WINDOWS:-0}" | ||
output_path="" | ||
agpl="${CODER_BUILD_AGPL:-0}" | ||
|
||
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin -- "$@")" | ||
args="$(getopt -o "" -l version:,os:,arch:,output:,slim,agpl,sign-darwin,sign-windows -- "$@")" | ||
eval set -- "$args" | ||
while true; do | ||
case "$1" in | ||
|
@@ -68,6 +69,10 @@ while true; do | |
sign_darwin=1 | ||
shift | ||
;; | ||
--sign-windows) | ||
sign_windows=1 | ||
shift | ||
;; | ||
--) | ||
shift | ||
break | ||
|
@@ -93,6 +98,20 @@ if [[ "$sign_darwin" == 1 ]]; then | |
requiredenvs AC_CERTIFICATE_FILE AC_CERTIFICATE_PASSWORD_FILE | ||
fi | ||
|
||
if [[ "$sign_windows" == 1 ]]; then | ||
dependencies osslsigncode | ||
requiredenvs AUTHENTICODE_CERTIFICATE_FILE AUTHENTICODE_CERTIFICATE_PASSWORD_FILE | ||
fi | ||
|
||
if [[ "$os" == "windows" ]]; then | ||
goversioninfo -platform-specific=true \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the following files are outputted in
Need to embed the appropriate arch into the appropriate windows build. |
||
-product-version=${version} \ | ||
-icon=cmd/coder/coder.exe.ico \ | ||
-manifest=cmd/coder/coder.exe.manifest \ | ||
cmd/coder/versioninfo.json | ||
fi | ||
|
||
|
||
build_args=( | ||
-ldflags "-s -w -X 'github.com/coder/coder/buildinfo.tag=$version'" | ||
) | ||
|
@@ -134,4 +153,8 @@ if [[ "$sign_darwin" == 1 ]] && [[ "$os" == "darwin" ]]; then | |
execrelative ./sign_darwin.sh "$output_path" 1>&2 | ||
fi | ||
|
||
if [[ "$sign_windows" == 1 ]] && [[ "$os" == "windows" ]]; then | ||
execrelative ./sign_windows.sh "$output_path" 1>&2 | ||
fi | ||
|
||
echo "$output_path" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
# This script signs the provided windows binary with a X.509 certificate and | ||
# it's associated private key. | ||
# | ||
# Usage: ./sign_windows.sh path/to/binary | ||
# | ||
# On success, the input file will be signed using the X.509 certificate. | ||
# | ||
# You can check if a binary is signed by running the following command: | ||
# osslsigncode verify path/to/binary | ||
# | ||
# Depends on the osslsigncode utility. Requires the following environment variables | ||
# to be set: | ||
# - $AUTHENTICODE_CERTIFICATE_FILE: The path to the X5.09 certificate file. | ||
# - $AUTHENTICODE_CERTIFICATE_PASSWORD_FILE: The path to the file containing the password | ||
# for the X5.09 certificate. | ||
|
||
set -euo pipefail | ||
# shellcheck source=scripts/lib.sh | ||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" | ||
|
||
# Check dependencies | ||
dependencies osslsigncode | ||
requiredenvs AUTHENTICODE_CERTIFICATE_FILE AUTHENTICODE_CERTIFICATE_PASSWORD_FILE | ||
|
||
osslsigncode sign \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Signing of windows executables in the next year is migrating [1] to requiring storage of the certificate to be within a hardware appliance (ie Google Cloud HSM). [1] https://twitter.com/vcsjones/status/1595236155276120065 and https://knowledge.digicert.com/generalinformation/new-private-key-storage-requirement-for-standard-code-signing-certificates-november-2022.html |
||
-pkcs12 "$AUTHENTICODE_CERTIFICATE_FILE" \ | ||
-readpass "$AUTHENTICODE_CERTIFICATE_PASSWORD_FILE" \ | ||
-n "Coder" \ | ||
-i "https://coder.com" \ | ||
-t "http://timestamp.sectigo.com" | ||
-in "$@" \ | ||
-out "$@" \ | ||
1>&2 | ||
|
||
osslsigncodeosslsigncode verify "$@" 1>&2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've set this at
0
by default under assumption that we will obtain the signing certificate and install it afterwards as part of a seperate pull-request as signing certificates will take a couple of weeks.