mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
feat: sign windows binaries (#13086)
This commit is contained in:
@@ -35,6 +35,7 @@ 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}"
|
||||
boringcrypto=${CODER_BUILD_BORINGCRYPTO:-0}
|
||||
@@ -106,6 +107,11 @@ if [[ "$sign_darwin" == 1 ]]; then
|
||||
requiredenvs AC_CERTIFICATE_FILE AC_CERTIFICATE_PASSWORD_FILE
|
||||
fi
|
||||
|
||||
if [[ "$sign_windows" == 1 ]]; then
|
||||
dependencies java
|
||||
requiredenvs JSIGN_PATH EV_KEYSTORE EV_KEY EV_CERTIFICATE_PATH EV_TSA_URL GCLOUD_ACCESS_TOKEN
|
||||
fi
|
||||
|
||||
ldflags=(
|
||||
-X "'github.com/coder/coder/v2/buildinfo.tag=$version'"
|
||||
)
|
||||
@@ -176,4 +182,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"
|
||||
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script signs the provided windows binary with an Extended Validation
|
||||
# code signing certificate.
|
||||
#
|
||||
# Usage: ./sign_windows.sh path/to/binary
|
||||
#
|
||||
# On success, the input file will be signed using the EV cert.
|
||||
#
|
||||
# Depends on the jsign utility (and thus Java). Requires the following environment variables
|
||||
# to be set:
|
||||
# - $JSIGN_PATH: The path to the jsign jar.
|
||||
# - $EV_KEYSTORE: The name of the keyring containing the private key
|
||||
# - $EV_KEY: The name of the key.
|
||||
# - $EV_CERTIFICATE_PATH: The path to the certificate.
|
||||
# - $EV_TSA_URL: The url of the timestamp server to use.
|
||||
|
||||
set -euo pipefail
|
||||
# shellcheck source=scripts/lib.sh
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
||||
|
||||
# Check dependencies
|
||||
dependencies java
|
||||
requiredenvs JSIGN_PATH EV_KEYSTORE EV_KEY EV_CERTIFICATE_PATH EV_TSA_URL GCLOUD_ACCESS_TOKEN
|
||||
|
||||
java -jar "$JSIGN_PATH" \
|
||||
--storetype GOOGLECLOUD \
|
||||
--storepass "$GCLOUD_ACCESS_TOKEN" \
|
||||
--keystore "$EV_KEYSTORE" \
|
||||
--alias "$EV_KEY" \
|
||||
--certfile "$EV_CERTIFICATE_PATH" \
|
||||
--tsmode RFC3161 \
|
||||
--tsaurl "$EV_TSA_URL" \
|
||||
"$@" \
|
||||
1>&2
|
||||
Reference in New Issue
Block a user