Skip to content

Commit 79dcde6

Browse files
author
Marc-André Moreau
committed
migrate to use AzureSignTool + Azure Key Vault for code signing
1 parent b2a3849 commit 79dcde6

File tree

5 files changed

+47
-95
lines changed

5 files changed

+47
-95
lines changed

.github/workflows/build-tools.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
name: sign ${{ matrix.tool }} [${{ matrix.platform }} ${{ matrix.arch }}]
9292
runs-on: ${{ matrix.runner }}
9393
needs: [ build, lipo ]
94-
environment: build-and-publish
94+
environment: publish-prod
9595
strategy:
9696
matrix:
9797
arch: [ x86_64, aarch64, universal ]
@@ -121,17 +121,11 @@ jobs:
121121
$Path += ".exe"
122122
}
123123
echo "binary-path=$Path" >> $Env:GITHUB_OUTPUT
124-
125-
- name: Configure certificates
124+
125+
- name: Install AzureSignTool
126126
if: matrix.platform == 'pc-windows-msvc'
127-
env:
128-
CODE_SIGN_CERT: ${{ secrets.WINDOWS_CODE_SIGNING_CERTIFICATE }}
129-
CODE_SIGN_CERT_PASSWORD: ${{ secrets.WINDOWS_CODE_SIGNING_PASSWORD }}
130127
run: |
131-
$CertificatePath = Join-Path -Path $Env:RUNNER_TEMP -ChildPath CodeSigningCertificate.pfx
132-
[IO.File]::WriteAllBytes($CertificatePath, ([Convert]::FromBase64String($Env:CODE_SIGN_CERT)))
133-
$SecurePassword = ConvertTo-SecureString "$Env:CODE_SIGN_CERT_PASSWORD" -AsPlainText -Force
134-
Import-PfxCertificate -FilePath "$CertificatePath" -CertStoreLocation Cert:\CurrentUser\My -Password $SecurePassword
128+
dotnet tool install --global AzureSignTool
135129
136130
- name: Configure certificates
137131
if: matrix.platform == 'apple-darwin'
@@ -160,16 +154,15 @@ jobs:
160154
shell: pwsh
161155
run: |
162156
if ('${{ matrix.platform }}' -Eq 'pc-windows-msvc') {
163-
$SignCmd = $(@(
164-
'signtool',
165-
'sign',
166-
'/fd', 'SHA256',
167-
'/v',
168-
'/n', 'Devolutions',
169-
'/tr', 'http://timestamp.comodoca.com/?td=sha256',
170-
'/td', 'sha256',
171-
'${{ steps.get-binary-path.outputs.binary-path }}'
172-
)) -Join ' '
157+
$Params = @('sign',
158+
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
159+
'-kvu', '${{ secrets.CODE_SIGNING_KEYVAULT_URL }}',
160+
'-kvi', '${{ secrets.CODE_SIGNING_CLIENT_ID }}',
161+
'-kvs', '${{ secrets.CODE_SIGNING_CLIENT_SECRET }}',
162+
'-kvc', '${{ secrets.CODE_SIGNING_CERTIFICATE_NAME }}',
163+
'-tr', '${{ vars.CODE_SIGNING_TIMESTAMP_SERVER }}',
164+
'-v')
165+
AzureSignTool @Params '${{ steps.get-binary-path.outputs.binary-path }}'
173166
} elseif ('${{ matrix.platform }}' -Eq 'apple-darwin') {
174167
$SignCmd = $(@(
175168
'codesign',
@@ -180,11 +173,10 @@ jobs:
180173
'-v',
181174
'${{ steps.get-binary-path.outputs.binary-path }}'
182175
)) -Join ' '
176+
Write-Host $SignCmd
177+
Invoke-Expression $SignCmd
183178
}
184179
185-
Write-Host $SignCmd
186-
Invoke-Expression $SignCmd
187-
188180
- name: Verification
189181
shell: pwsh
190182
run: |

.github/workflows/package.yml

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
codesign:
131131
name: Codesign
132132
runs-on: ${{ matrix.runner }}
133-
environment: build-and-publish
133+
environment: publish-prod
134134
needs: preflight
135135
strategy:
136136
matrix:
@@ -179,18 +179,12 @@ jobs:
179179
$Destination = Join-Path ${{ runner.temp }} ${{ matrix.project }}
180180
if ('${{ matrix.project }}' -Eq 'jetsocat') {
181181
Get-ChildItem "$Destination" -Exclude ${{ matrix.os }} | Remove-Item -Recurse
182-
}
182+
}
183183
184-
- name: Configure certificates (Windows)
184+
- name: Install AzureSignTool
185185
if: matrix.os == 'windows'
186-
env:
187-
CODE_SIGN_CERT: ${{ secrets.WINDOWS_CODE_SIGNING_CERTIFICATE }}
188-
CODE_SIGN_CERT_PASSWORD: ${{ secrets.WINDOWS_CODE_SIGNING_PASSWORD }}
189186
run: |
190-
$CertificatePath = Join-Path -Path $Env:RUNNER_TEMP -ChildPath CodeSigningCertificate.pfx
191-
[IO.File]::WriteAllBytes($CertificatePath, ([Convert]::FromBase64String($Env:CODE_SIGN_CERT)))
192-
$SecurePassword = ConvertTo-SecureString "$Env:CODE_SIGN_CERT_PASSWORD" -AsPlainText -Force
193-
Import-PfxCertificate -FilePath "$CertificatePath" -CertStoreLocation Cert:\CurrentUser\My -Password $SecurePassword
187+
dotnet tool install --global AzureSignTool
194188
195189
- name: Configure certificates (macOS)
196190
if: matrix.os == 'macos'
@@ -227,16 +221,15 @@ jobs:
227221
}
228222
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include "$Pattern" | % {
229223
if ('${{ matrix.os }}' -Eq 'windows') {
230-
$SignCmd = $(@(
231-
'signtool',
232-
'sign',
233-
'/fd', 'SHA256',
234-
'/v',
235-
'/n', 'Devolutions',
236-
'/tr', 'http://timestamp.comodoca.com/?td=sha256',
237-
'/td', 'sha256',
238-
$_.FullName
239-
)) -Join ' '
224+
$Params = @('sign',
225+
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
226+
'-kvu', '${{ secrets.CODE_SIGNING_KEYVAULT_URL }}',
227+
'-kvi', '${{ secrets.CODE_SIGNING_CLIENT_ID }}',
228+
'-kvs', '${{ secrets.CODE_SIGNING_CLIENT_SECRET }}',
229+
'-kvc', '${{ secrets.CODE_SIGNING_CERTIFICATE_NAME }}',
230+
'-tr', '${{ vars.CODE_SIGNING_TIMESTAMP_SERVER }}',
231+
'-v')
232+
AzureSignTool @Params $_.FullName
240233
} elseif ('${{ matrix.os }}' -Eq 'macos') {
241234
$SignCmd = $(@(
242235
'codesign',
@@ -246,14 +239,11 @@ jobs:
246239
'-v',
247240
$_.FullName
248241
)) -Join ' '
242+
Write-Host $SignCmd
243+
Invoke-Expression $SignCmd
249244
} else {
250245
echo "::debug::nothing to do for ${{ matrix.os }}"
251246
}
252-
253-
if ($SignCmd) {
254-
Write-Host $SignCmd
255-
Invoke-Expression $SignCmd
256-
}
257247
}
258248
259249
- name: Add msbuild to PATH
@@ -280,21 +270,17 @@ jobs:
280270
if: matrix.project == 'devolutions-gateway'
281271
shell: pwsh
282272
run: |
283-
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include '*.msi' | % {
284-
$SignCmd = $(@(
285-
'signtool',
286-
'sign',
287-
'/fd', 'SHA256',
288-
'/v',
289-
'/n', 'Devolutions',
290-
'/tr', 'http://timestamp.comodoca.com/?td=sha256',
291-
'/d', '"Devolutions Gateway"',
292-
'/td', 'sha256',
293-
$_.FullName
294-
)) -Join ' '
295-
296-
Write-Host $SignCmd
297-
Invoke-Expression $SignCmd
273+
Get-ChildItem -Path ${{ runner.temp }} -Recurse -Include '*.msi' | % {
274+
$Params = @('sign',
275+
'-kvt', '${{ secrets.AZURE_TENANT_ID }}',
276+
'-kvu', '${{ secrets.CODE_SIGNING_KEYVAULT_URL }}',
277+
'-kvi', '${{ secrets.CODE_SIGNING_CLIENT_ID }}',
278+
'-kvs', '${{ secrets.CODE_SIGNING_CLIENT_SECRET }}',
279+
'-kvc', '${{ secrets.CODE_SIGNING_CERTIFICATE_NAME }}',
280+
'-tr', '${{ vars.CODE_SIGNING_TIMESTAMP_SERVER }}',
281+
'-d', 'Devolutions Gateway',
282+
'-v')
283+
AzureSignTool @Params $_.FullName
298284
}
299285
300286
- name: Verification

.github/workflows/publish-clients.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
nuget-publish:
9999
name: Publish NuGet packages
100100
runs-on: ubuntu-20.04
101-
environment: build-and-publish
101+
environment: publish-prod
102102
if: needs.preflight.outputs.dry-run == 'false'
103103
needs:
104104
- preflight
@@ -139,7 +139,7 @@ jobs:
139139
npm-publish:
140140
name: Publish NPM packages
141141
runs-on: ubuntu-20.04
142-
environment: build-and-publish
142+
environment: publish-prod
143143
if: needs.preflight.outputs.dry-run == 'false'
144144
needs:
145145
- preflight

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
containers:
103103
name: Containers [${{ matrix.os }} ${{ matrix.base-image }}]
104104
runs-on: ${{ matrix.runner }}
105-
environment: build-and-publish
105+
environment: publish-prod
106106
needs: preflight
107107
if: needs.preflight.outputs.skip-publishing == 'false' || github.event.inputs.dry-run == 'true'
108108
strategy:
@@ -209,7 +209,7 @@ jobs:
209209
github-release:
210210
name: GitHub release
211211
runs-on: ubuntu-20.04
212-
environment: build-and-publish
212+
environment: publish-prod
213213
needs: preflight
214214
if: needs.preflight.outputs.skip-publishing == 'false' || github.event.inputs.dry-run == 'true'
215215

@@ -286,7 +286,7 @@ jobs:
286286
psgallery-release:
287287
name: PowerShell release
288288
runs-on: ubuntu-20.04
289-
environment: build-and-publish
289+
environment: publish-prod
290290
needs: preflight
291291
if: needs.preflight.outputs.skip-publishing == 'false' || github.event.inputs.dry-run == 'true'
292292

ci/tlk.ps1

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -336,19 +336,6 @@ class TlkRecipe
336336

337337
if ($DestinationExecutable) {
338338
Copy-Item -Path $SrcExecutablePath -Destination $DestinationExecutable
339-
340-
if (Test-Path Env:SIGNTOOL_NAME) {
341-
$SignToolName = $Env:SIGNTOOL_NAME
342-
$TimestampServer = 'http://timestamp.comodoca.com/?td=sha256'
343-
$SignToolArgs = @(
344-
'sign', '/fd', 'SHA256', '/v',
345-
'/n', $SignToolName,
346-
'/tr', $TimestampServer,
347-
'/td', 'sha256',
348-
$DestinationExecutable
349-
)
350-
& 'signtool' $SignToolArgs | Out-Host
351-
}
352339
}
353340

354341
Pop-Location
@@ -449,19 +436,6 @@ class TlkRecipe
449436
if (Test-Path Env:DGATEWAY_PACKAGE) {
450437
$DGatewayPackage = $Env:DGATEWAY_PACKAGE
451438
Copy-Item -Path "$($this.PackageName).msi" -Destination $DGatewayPackage
452-
453-
if (Test-Path Env:SIGNTOOL_NAME) {
454-
$SignToolName = $Env:SIGNTOOL_NAME
455-
$TimestampServer = 'http://timestamp.comodoca.com/?td=sha256'
456-
$SignToolArgs = @(
457-
'sign', '/fd', 'SHA256', '/v',
458-
'/n', $SignToolName,
459-
'/tr', $TimestampServer,
460-
'/td', 'sha256',
461-
$DGatewayPackage
462-
)
463-
& 'signtool' $SignToolArgs | Out-Host
464-
}
465439
}
466440

467441
Pop-Location
@@ -471,7 +445,7 @@ class TlkRecipe
471445
$DebianArchitecture = $this.Target.DebianArchitecture()
472446
$Packager = "Devolutions Inc."
473447
$Email = "[email protected]"
474-
$Website = "http://wayk.devolutions.net"
448+
$Website = "https://devolutions.net"
475449
$PackageVersion = $this.Version
476450
$DistroCodeName = "xenial" # Ubuntu 16.04
477451
$Dependencies = @('liblzma5', 'liblz4-1', '${shlibs:Depends}', '${misc:Depends}')

0 commit comments

Comments
 (0)