Skip to content

Fix GitHub App Key Vault signing - #17271

Merged
mmitche merged 1 commit into
dotnet:mainfrom
missymessa:missymessa/fix-github-app-sign-warning
Aug 6, 2026
Merged

mmitche merged 1 commit into
dotnet:mainfrom
missymessa:missymessa/fix-github-app-sign-warning

Conversation

@missymessa

Copy link
Copy Markdown
Member

Summary

  • determine Key Vault signing success from the Azure CLI exit code so non-fatal stderr warnings do not abort OneLocBuild
  • query the signature field returned by az keyvault key sign
  • convert the standard Base64 signature to Base64URL before constructing the GitHub App JWT

Validation

  • signed a test digest with oneloc-localization-app-key without exposing signature material
  • used the resulting JWT to successfully list the GitHub App installations and locate the dotnet installation
  • parsed the updated PowerShell script and ran git diff --check

Fixes the OneLocBuild failure observed in build 3041074.

Authored with GitHub Copilot CLI.

Use the Azure CLI exit code rather than treating non-fatal stderr warnings as command failures. Query the actual signature field and convert its standard Base64 representation to JWT-compatible Base64URL encoding.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 3eb6a0bd-11cc-4d7a-97ce-16e5d553f215
Copilot AI review requested due to automatic review settings August 6, 2026 19:25
Comment thread eng/common/Get-GitHubAppToken.ps1 Resolved
@mmitche
mmitche disabled auto-merge August 6, 2026 19:41
@mmitche
mmitche merged commit 2cf38de into dotnet:main Aug 6, 2026
5 of 12 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Fixes GitHub App JWT signing via Azure Key Vault by avoiding failures from non-fatal Azure CLI stderr output and by correctly formatting the signature for JWT usage.

Changes:

  • Determine az keyvault key sign success using the process exit code rather than stderr handling.
  • Query the signature field directly from the Azure CLI output.
  • Convert the returned signature from Base64 to Base64URL before composing the JWT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$digestBase64 = [Convert]::ToBase64String($digestBytes)

Write-Host "Signing JWT with key '$KeyName' in vault '$KeyVaultName'..."
$previousNativeCommandErrorPreference = $PSNativeCommandUseErrorActionPreference
$signatureUrl = az keyvault key sign `
# Azure CLI can emit non-fatal Python warnings to stderr even when signing succeeds.
# Use the exit code to determine success for this invocation.
$PSNativeCommandUseErrorActionPreference = $false
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($signatureUrl)) {
Write-PipelineTelemetryError -Category 'Build' -Message "'az keyvault key sign' exited with code $LASTEXITCODE for key '$KeyName' in vault '$KeyVaultName'. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
finally {
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandErrorPreference
# Azure CLI can emit non-fatal Python warnings to stderr even when signing succeeds.
# Use the exit code to determine success for this invocation.
$PSNativeCommandUseErrorActionPreference = $false
$signatureBase64 = az keyvault key sign `
--algorithm RS256 `
--digest $digestBase64 `
--query value `
--query signature `
Comment on lines +97 to +98
if ($signExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($signatureBase64)) {
Write-PipelineTelemetryError -Category 'Build' -Message "'az keyvault key sign' exited with code $signExitCode for key '$KeyName' in vault '$KeyVaultName'. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants