Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Actions/Sign/Sign.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ function Invoke-SigningTool() {
$FilesToSign
}
}

$signingExitCode = $LASTEXITCODE
if ($signingExitCode -ne 0) {
throw "Signing tool failed with exit code $signingExitCode."
}
}

Export-ModuleMember -Function Invoke-SigningTool
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Issues

- Issue 2452 - Fail the signing action when the signing tool returns a nonzero exit code for Trusted Signing or Azure Key Vault signing.

- Issue 2405 - Fix AppSource publishing failures reporting duplicate extension IDs when multiple versions of the same dependency are included. Only the highest included version is submitted.

## v10.1
Expand Down
2 changes: 2 additions & 0 deletions Scenarios/Codesigning.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ On June 1st 2023 the industry standards for storing code signing certificates ch

This guide will take you through how to set up your AL-Go project with an Azure Key Vault and how to use a certificate in the Key Vault to perform code signing. Before you get started, please make sure you've set up your AL-Go project with an Azure Key Vault by following [Scenario 7: Use Azure KeyVault for secrets with AL-Go](./UseAzureKeyVault.md).

For both Azure Key Vault and Trusted Signing, a nonzero signing-tool exit code fails the signing action and is included in the error message. Individual diagnostic log messages do not determine whether signing succeeded.

> [!NOTE]
> If your code signing certificate was issued after June 1st 2023 you will most likely need to create a Premium SKU Key Vault. You can [learn more about the differences between Standard and Premium SKU here](https://azure.microsoft.com/en-us/pricing/details/key-vault/)

Expand Down
68 changes: 67 additions & 1 deletion Tests/Sign.Test.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Get-Module TestActionsHelper | Remove-Module -Force
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Justification = 'Test case parameters are used inside Pester assertion scriptblocks')]
param()

Get-Module TestActionsHelper | Remove-Module -Force
Import-Module (Join-Path $PSScriptRoot 'TestActionsHelper.psm1')
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0

Import-Module (Join-Path $PSScriptRoot '..\Actions\Sign\Sign.psm1') -Force -DisableNameChecking

Describe "Sign Action Tests" {
BeforeAll {
$actionName = "Sign"
Expand All @@ -26,3 +31,64 @@ Describe "Sign Action Tests" {
# Call action

}

InModuleScope Sign {
$signingTestCases = @(
@{
Name = 'Trusted Signing'
SigningParameters = @{
SigningEndpoint = 'https://example.com'
SigningAccount = 'test-account'
SigningCertificateProfile = 'test-profile'
}
},
@{
Name = 'Key Vault client secret'
SigningParameters = @{
KeyVaultName = 'test-vault'
CertificateName = 'test-certificate'
ClientId = 'test-client'
ClientSecret = 'test-secret'
TenantId = 'test-tenant'
}
},
@{
Name = 'Key Vault managed identity'
SigningParameters = @{
KeyVaultName = 'test-vault'
CertificateName = 'test-certificate'
}
}
)

Describe 'Signing tool exit status' {
BeforeEach {
$script:signingExitCode = 0
Mock Install-SigningTool {
return {
# Exercise native exit codes without installing the signer or contacting Azure.
$PSNativeCommandUseErrorActionPreference = $false
& (Get-Process -Id $PID).Path -NoProfile -NonInteractive -Command "exit $script:signingExitCode"
}
}
}

It 'Fails with the native exit code for <Name>' -TestCases $signingTestCases {
param($Name, $SigningParameters)

$script:signingExitCode = 23

{
Invoke-SigningTool @SigningParameters -FilesToSign '*.app' -Description $Name -DescriptionUrl 'https://example.com'
} | Should -Throw 'Signing tool failed with exit code 23.'
}

It 'Succeeds with a zero native exit code for <Name>' -TestCases $signingTestCases {
param($Name, $SigningParameters)

{
Invoke-SigningTool @SigningParameters -FilesToSign '*.app' -Description $Name -DescriptionUrl 'https://example.com'
} | Should -Not -Throw
}
}
}
Loading