Skip to content

Commit

Permalink
Merge pull request #27 from github/windows-installer-signing
Browse files Browse the repository at this point in the history
Windows installer signing
  • Loading branch information
mastahyeti authored Oct 2, 2018
2 parents 55a305c + 3f80ebc commit e0db87f
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ os: 'Visual Studio 2015'

clone_folder: C:\gopath\src\github.com\github\smimesign

environment:
pfx_password:
secure: WfQzoLeQ6dGF2NnDKhZX6ai/k5s+qWyWLdIZoAjPineepfZeXovgrB2bmOtZfO2d

init:
# Always build with CGO
- set CGO_ENABLED=1
# Paths and Go environment
- set GOPATH=c:\gopath
- set GOROOT=c:\go
- set PATH=%GOROOT%\bin;%GOPATH%\bin;C:\msys64\usr\bin;%PATH%
- set PATH=%GOROOT%\bin;%GOPATH%\bin;C:\msys64\usr\bin;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
- set PATH_WAS=%PATH%

install:
Expand Down Expand Up @@ -39,8 +43,14 @@ build_script:
- go build -o smimesign-386.exe -ldflags "-X main.versionString=%GIT_VERSION%" .

after_build:
# Sign binaries
- if "%pfx_password%" NEQ "" (signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p %pfx_password% /f windows-installer\codesign.pfx smimesign-amd64.exe)
- if "%pfx_password%" NEQ "" (signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p %pfx_password% /f windows-installer\codesign.pfx smimesign-386.exe)
# Build installer
- iscc windows-installer/inno-setup-smimesign-installer.iss
# Sign installer — AppVeyor's "secure variables" aren't included in PR builds,
# so we skip this step if the PFX password is missing.
- if "%pfx_password%" NEQ "" (signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /p %pfx_password% /f windows-installer\codesign.pfx smimesign-windows-*.exe)

test_script:
- go test -v ./...
Expand Down
79 changes: 79 additions & 0 deletions windows-installer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TSEltf
+VgYNbxHzaE2+Wt/1LA4PsEbw4wz2dgvGP4oD7Ong9bDbkTAYTWWFv5ZnIt2bdfx
oksNK/8LctqeYNCOkDXGeFWHIKHP5W0KyEl8MZgzbCLph9AyWqK6E4IR7TkXnZk6
cqHm+qTZ1Rcxda6FfSKuPwFGhvYoecix2uRXF8R+HA6wtJKmVrO9spftqqfwt8Wo
P5UW0P+hlusIXxh3TwIDAQABo2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/
BAUwAwEB/zAdBgNVHQ4EFgQUReuir/SSy4IxLVGLp6chnfNtyA8wHwYDVR0jBBgw
FoAUReuir/SSy4IxLVGLp6chnfNtyA8wDQYJKoZIhvcNAQEFBQADggEBAKIOvN/i
7fDjcnN6ZJS/93Jm2DLkQnVirofr8tXZ3lazn8zOFCi5DZdgXBJMWOTTPYNJRViX
NWkaqEfqVsZ5qxLYZ4GE338JPJTmuCYsIL09syiJ91//IuKXhB/pZe+H4N/BZ0mz
XeuyCSrrJu14vn0/K/O3JjVtX4kBtklbnwEFm6s9JcHMtn/C8W+GxvpkaOuBLZTr
Qrf6jB7dYvG+UGe3bL3z8R9rDDYHFn83fKlbbXrxEkZgg9cnBL5Lzpe+w2cqaBHf
gOcMM2a/Ew0UbvN/H2MQHvqNGyVtbI+lt2EBsdKjJqEQcZ2t4sP5w5lRtysHCM4u
5lCyp/oKRS+i8PIxAA==
-----END PKCS7-----
19 changes: 19 additions & 0 deletions windows-installer/codesign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Code-signing certificate request

[ req ]
default_md = sha256
distinguished_name = github_dn
req_extensions = codesign_reqext
prompt = no

[ github_dn ]
countryName = "US"
stateOrProvinceName = "CA"
localityName = "San Francisco"
organizationName = "GitHub, Inc."
commonName = "GitHub, Inc."

[ codesign_reqext ]
keyUsage = critical,digitalSignature
extendedKeyUsage = critical,codeSigning
subjectKeyIdentifier = hash
Binary file added windows-installer/codesign.pfx
Binary file not shown.
10 changes: 10 additions & 0 deletions windows-installer/genreate-csr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

export KEY_PASSWORD=$(head -n100 /dev/urandom | shasum -a256 | awk '{print $1}')
echo "Key passphrase (save this): $KEY_PASSWORD"

openssl req -new -utf8 -out req.pem -newkey rsa:2048 -keyout key.pem -passout env:KEY_PASSWORD -config codesign.conf



30 changes: 30 additions & 0 deletions windows-installer/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIkFSJC5YgS5wCAggA
MB0GCWCGSAFlAwQBKgQQAvG9OtlSUFI8ESm2pdM2iASCBNDe5qxtAIHMNcAeJ4bM
e0DY9KMLwSe4IoyDRYXf4Ajzg/rnaljTVviozQvCIAfKkldVnQvn/QeJnFl3k89n
29+uKv8jE/5PUO5YTrzdY2FzR4KJpiWyww9E94ld8dtTjmZWJok6Vx/bGUL1Od40
MNSeyBqM2XEHE2829IWhwfxkapzCU575UTjUamMprPZR31sFrGYKI0LJzR9g93VZ
9PG7hviTwj5Rcx2H5CD+sLkZWEYz9imvFeRS/Erz485T8X8L8sLOliYmz5YleXL5
J5vE/0faNf8UspF4ogslWRrs6NRUFWJ4ifJZh9pWME7OlWbjRsoGWzvKLpZvEr2F
H73pFvs+rJTxJwRlz31LKT3SbC+y1sdpsbt6yQMp+h/Q48qQlZEB7+Cv90zy2GGL
oZQHOEfCADvVeNYZyKaBg1wDf7sNogDIT4NVkCJdtXNRa+3kHEP75Ov9qRMSl4Gw
3zxIjkwyeB0O4zwUSWjjZbUhbP5TiETzPWqnbPmU1tAYn10kha4wi7I5nTauWk+S
rU4+kwmtp2XgwTJ/UeP1TtTBjOBPZhrJzbp158CIEWjxYC2nIHO5Exxwx2KQI8yB
RXF39JZWw7OflG4MC0KZ3XezOmz1OGFpNIYCiuKVQO3MMVscV1O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sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

# use sha1, since there is a max pw length
export KEY_PASSWORD=$(head -n100 /dev/urandom | shasum | awk '{print $1}')
echo "PFX passphrase (save this): $KEY_PASSWORD"

openssl pkcs7 -in chain.p7b -inform PEM -out result.pem -print_certs
trap "rm result.pem" EXIT

openssl pkcs12 -export -inkey key.pem -in result.pem -out codesign.pfx -passout env:KEY_PASSWORD

19 changes: 19 additions & 0 deletions windows-installer/req.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIC/TCCAeUCAQAwYDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQH
DA1TYW4gRnJhbmNpc2NvMRUwEwYDVQQKDAxHaXRIdWIsIEluYy4xFTATBgNVBAMM
DEdpdEh1YiwgSW5jLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANeQ
ONSLQqZiKtebemA1xqZGa/FF7pRw6ZDllQ2ny5YcFNMbh321njwqWtBgNBrygoIs
RQ/WZpbAvYYxU+//ZZS4DwQ7/eYRZxXmvmk7LPx65LTd1mzrBkKVv81e9hgtuxkZ
o5r+axSd6H2CMqg+thnyvGg96Xzs9q4Cn9OTYkD/x6oZtD5Cl0hWGtQHbC5urY1z
9l9aDattr2g7/WtgNTxOeARP7pfc2rqnvEy2/NynH902Ip/CxVWhHs0PxPNOCvwN
uCcDH8c5eCsvTB8z6a3RNaS87+hm7k91qu0NH7a5PG+OWnrpwdDtkNSlxQLNRPVX
7OxlFLfn/m/unCZt3J8CAwEAAaBYMFYGCSqGSIb3DQEJDjFJMEcwDgYDVR0PAQH/
BAQDAgeAMBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMDMB0GA1UdDgQWBBTt0q+YHS29
llXN+SUgerJHSKtpWTANBgkqhkiG9w0BAQsFAAOCAQEAUmxgOFiqHIVo3BoVwPUb
Iqr5BVOFf+/FV6Y02Yh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