Skip to content

Commit 9e2d55a

Browse files
Update dependencies from build 342624
Updated Dependencies: Microsoft.DotNet.Arcade.Sdk, Microsoft.DotNet.Build.Tasks.Templating, Microsoft.DotNet.Helix.Sdk (Version 12.0.0-beta.26565.104 -> 12.0.0-beta.26571.109) Microsoft.Extensions.Caching.Memory, Microsoft.Extensions.Configuration, Microsoft.Extensions.Configuration.EnvironmentVariables, Microsoft.Extensions.Configuration.Json, Microsoft.Extensions.DependencyInjection, Microsoft.Extensions.DependencyModel, Microsoft.Extensions.HostFactoryResolver.Sources, Microsoft.Extensions.Logging, Microsoft.NETCore.App.Ref, Microsoft.NETCore.Platforms, System.Formats.Asn1, System.Runtime.Caching, System.Text.Encodings.Web, System.Text.Json (Version 12.0.0-alpha.1.26565.104 -> 12.0.0-alpha.1.26571.109) [[ commit created by automation ]]
1 parent bfd4aef commit 9e2d55a

10 files changed

Lines changed: 231 additions & 139 deletions

File tree

‎eng/Version.Details.props‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ This file should be imported by eng/Versions.props
66
<Project>
77
<PropertyGroup>
88
<!-- dotnet-dotnet dependencies -->
9-
<MicrosoftDotNetArcadeSdkPackageVersion>12.0.0-beta.26565.104</MicrosoftDotNetArcadeSdkPackageVersion>
10-
<MicrosoftDotNetBuildTasksTemplatingPackageVersion>12.0.0-beta.26565.104</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
11-
<MicrosoftDotNetHelixSdkPackageVersion>12.0.0-beta.26565.104</MicrosoftDotNetHelixSdkPackageVersion>
12-
<MicrosoftExtensionsCachingMemoryPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsCachingMemoryPackageVersion>
13-
<MicrosoftExtensionsConfigurationPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsConfigurationPackageVersion>
14-
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
15-
<MicrosoftExtensionsConfigurationJsonPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsConfigurationJsonPackageVersion>
16-
<MicrosoftExtensionsDependencyInjectionPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsDependencyInjectionPackageVersion>
17-
<MicrosoftExtensionsDependencyModelPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsDependencyModelPackageVersion>
18-
<MicrosoftExtensionsHostFactoryResolverSourcesPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsHostFactoryResolverSourcesPackageVersion>
19-
<MicrosoftExtensionsLoggingPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftExtensionsLoggingPackageVersion>
20-
<MicrosoftNETCoreAppRefPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftNETCoreAppRefPackageVersion>
21-
<MicrosoftNETCorePlatformsPackageVersion>12.0.0-alpha.1.26565.104</MicrosoftNETCorePlatformsPackageVersion>
22-
<SystemFormatsAsn1PackageVersion>12.0.0-alpha.1.26565.104</SystemFormatsAsn1PackageVersion>
23-
<SystemRuntimeCachingPackageVersion>12.0.0-alpha.1.26565.104</SystemRuntimeCachingPackageVersion>
24-
<SystemTextEncodingsWebPackageVersion>12.0.0-alpha.1.26565.104</SystemTextEncodingsWebPackageVersion>
25-
<SystemTextJsonPackageVersion>12.0.0-alpha.1.26565.104</SystemTextJsonPackageVersion>
9+
<MicrosoftDotNetArcadeSdkPackageVersion>12.0.0-beta.26571.109</MicrosoftDotNetArcadeSdkPackageVersion>
10+
<MicrosoftDotNetBuildTasksTemplatingPackageVersion>12.0.0-beta.26571.109</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
11+
<MicrosoftDotNetHelixSdkPackageVersion>12.0.0-beta.26571.109</MicrosoftDotNetHelixSdkPackageVersion>
12+
<MicrosoftExtensionsCachingMemoryPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsCachingMemoryPackageVersion>
13+
<MicrosoftExtensionsConfigurationPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsConfigurationPackageVersion>
14+
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
15+
<MicrosoftExtensionsConfigurationJsonPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsConfigurationJsonPackageVersion>
16+
<MicrosoftExtensionsDependencyInjectionPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsDependencyInjectionPackageVersion>
17+
<MicrosoftExtensionsDependencyModelPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsDependencyModelPackageVersion>
18+
<MicrosoftExtensionsHostFactoryResolverSourcesPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsHostFactoryResolverSourcesPackageVersion>
19+
<MicrosoftExtensionsLoggingPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftExtensionsLoggingPackageVersion>
20+
<MicrosoftNETCoreAppRefPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftNETCoreAppRefPackageVersion>
21+
<MicrosoftNETCorePlatformsPackageVersion>12.0.0-alpha.1.26571.109</MicrosoftNETCorePlatformsPackageVersion>
22+
<SystemFormatsAsn1PackageVersion>12.0.0-alpha.1.26571.109</SystemFormatsAsn1PackageVersion>
23+
<SystemRuntimeCachingPackageVersion>12.0.0-alpha.1.26571.109</SystemRuntimeCachingPackageVersion>
24+
<SystemTextEncodingsWebPackageVersion>12.0.0-alpha.1.26571.109</SystemTextEncodingsWebPackageVersion>
25+
<SystemTextJsonPackageVersion>12.0.0-alpha.1.26571.109</SystemTextJsonPackageVersion>
2626
</PropertyGroup>
2727
<!--Property group for alternate package version names-->
2828
<PropertyGroup>

‎eng/Version.Details.xml‎

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<Source Uri="https://github.com/dotnet/dotnet" Mapping="efcore" Sha="8fc142ba6d733754f83a1e9a9b87cad5de06b650" BarId="341531" />
3+
<Source Uri="https://github.com/dotnet/dotnet" Mapping="efcore" Sha="ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c" BarId="342624" />
44
<ProductDependencies>
5-
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="12.0.0-alpha.1.26565.104">
5+
<Dependency Name="Microsoft.Extensions.Caching.Memory" Version="12.0.0-alpha.1.26571.109">
66
<Uri>https://github.com/dotnet/dotnet</Uri>
7-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
7+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
88
</Dependency>
9-
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="12.0.0-alpha.1.26565.104">
9+
<Dependency Name="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="12.0.0-alpha.1.26571.109">
1010
<Uri>https://github.com/dotnet/dotnet</Uri>
11-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
11+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
1212
</Dependency>
13-
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="12.0.0-alpha.1.26565.104">
13+
<Dependency Name="Microsoft.Extensions.Configuration.Json" Version="12.0.0-alpha.1.26571.109">
1414
<Uri>https://github.com/dotnet/dotnet</Uri>
15-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
15+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
1616
</Dependency>
17-
<Dependency Name="Microsoft.Extensions.Configuration" Version="12.0.0-alpha.1.26565.104">
17+
<Dependency Name="Microsoft.Extensions.Configuration" Version="12.0.0-alpha.1.26571.109">
1818
<Uri>https://github.com/dotnet/dotnet</Uri>
19-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
19+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
2020
</Dependency>
21-
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="12.0.0-alpha.1.26565.104">
21+
<Dependency Name="Microsoft.Extensions.DependencyInjection" Version="12.0.0-alpha.1.26571.109">
2222
<Uri>https://github.com/dotnet/dotnet</Uri>
23-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
23+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
2424
</Dependency>
25-
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="12.0.0-alpha.1.26565.104">
25+
<Dependency Name="Microsoft.Extensions.DependencyModel" Version="12.0.0-alpha.1.26571.109">
2626
<Uri>https://github.com/dotnet/dotnet</Uri>
27-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
27+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
2828
</Dependency>
29-
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="12.0.0-alpha.1.26565.104">
29+
<Dependency Name="Microsoft.Extensions.HostFactoryResolver.Sources" Version="12.0.0-alpha.1.26571.109">
3030
<Uri>https://github.com/dotnet/dotnet</Uri>
31-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
31+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
3232
</Dependency>
33-
<Dependency Name="Microsoft.Extensions.Logging" Version="12.0.0-alpha.1.26565.104">
33+
<Dependency Name="Microsoft.Extensions.Logging" Version="12.0.0-alpha.1.26571.109">
3434
<Uri>https://github.com/dotnet/dotnet</Uri>
35-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
35+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
3636
</Dependency>
37-
<Dependency Name="Microsoft.NETCore.App.Ref" Version="12.0.0-alpha.1.26565.104">
37+
<Dependency Name="Microsoft.NETCore.App.Ref" Version="12.0.0-alpha.1.26571.109">
3838
<Uri>https://github.com/dotnet/dotnet</Uri>
39-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
39+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
4040
</Dependency>
41-
<Dependency Name="Microsoft.NETCore.Platforms" Version="12.0.0-alpha.1.26565.104">
41+
<Dependency Name="Microsoft.NETCore.Platforms" Version="12.0.0-alpha.1.26571.109">
4242
<Uri>https://github.com/dotnet/dotnet</Uri>
43-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
43+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
4444
</Dependency>
45-
<Dependency Name="System.Text.Json" Version="12.0.0-alpha.1.26565.104">
45+
<Dependency Name="System.Text.Json" Version="12.0.0-alpha.1.26571.109">
4646
<Uri>https://github.com/dotnet/dotnet</Uri>
47-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
47+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
4848
</Dependency>
49-
<Dependency Name="System.Text.Encodings.Web" Version="12.0.0-alpha.1.26565.104">
49+
<Dependency Name="System.Text.Encodings.Web" Version="12.0.0-alpha.1.26571.109">
5050
<Uri>https://github.com/dotnet/dotnet</Uri>
51-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
51+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
5252
</Dependency>
53-
<Dependency Name="System.Formats.Asn1" Version="12.0.0-alpha.1.26565.104">
53+
<Dependency Name="System.Formats.Asn1" Version="12.0.0-alpha.1.26571.109">
5454
<Uri>https://github.com/dotnet/dotnet</Uri>
55-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
55+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
5656
</Dependency>
57-
<Dependency Name="System.Runtime.Caching" Version="12.0.0-alpha.1.26565.104">
57+
<Dependency Name="System.Runtime.Caching" Version="12.0.0-alpha.1.26571.109">
5858
<Uri>https://github.com/dotnet/dotnet</Uri>
59-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
59+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
6060
</Dependency>
6161
</ProductDependencies>
6262
<ToolsetDependencies>
63-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="12.0.0-beta.26565.104">
63+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="12.0.0-beta.26571.109">
6464
<Uri>https://github.com/dotnet/dotnet</Uri>
65-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
65+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
6666
</Dependency>
67-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="12.0.0-beta.26565.104">
67+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="12.0.0-beta.26571.109">
6868
<Uri>https://github.com/dotnet/dotnet</Uri>
69-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
69+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
7070
</Dependency>
71-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="12.0.0-beta.26565.104">
71+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="12.0.0-beta.26571.109">
7272
<Uri>https://github.com/dotnet/dotnet</Uri>
73-
<Sha>8fc142ba6d733754f83a1e9a9b87cad5de06b650</Sha>
73+
<Sha>ee7a7c0752b641dc8c1142eb8f37fb1ec8510d0c</Sha>
7474
</Dependency>
7575
</ToolsetDependencies>
7676
</Dependencies>

‎eng/common/Get-GitHubAppToken.ps1‎

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Mints a short-lived GitHub App installation access token by signing a JWT
2-
# with an RSA private key (RS256). The signed JWT is exchanged with the GitHub
3-
# API for a token scoped to a single installation.
2+
# via Azure Key Vault's RSA signing operation (RS256). The private key never
3+
# leaves Key Vault. The JWT is exchanged for a single installation's token.
44
#
55
# Requirements:
6-
# - A GitHub App ID and PEM private key stored as Azure Key Vault secrets.
7-
# - The federated Azure service connection running this script must have
8-
# `Get` access to those two secrets.
6+
# - The GitHub App's private key imported as a Key Vault RSA key.
7+
# - Read access to the configured App-ID secret projection.
8+
# - The federated Azure service connection must have the `Sign` action on
9+
# that key. Reading private-key secrets is neither required nor supported.
910
# - The App must be installed on the target organization/account
1011
# (`InstallationOwner`) with the permissions/repositories it needs.
1112
#
@@ -14,17 +15,19 @@
1415

1516
[CmdletBinding()]
1617
param(
17-
# Name of the Key Vault holding the GitHub App credentials.
18+
# Key Vault holding the App-ID projection and RSA signing key.
1819
[Parameter(Mandatory = $true)]
1920
[string] $KeyVaultName,
2021

21-
# Secret Manager projection containing the GitHub App ID.
22+
# Name of the RSA signing key, not a Key Vault secret.
2223
[Parameter(Mandatory = $true)]
23-
[string] $AppIdSecretName,
24+
[ValidateNotNullOrEmpty()]
25+
[string] $KeyName,
2426

25-
# Secret Manager projection containing the PEM private key.
27+
# Secret Manager projection containing the GitHub App's public ID.
2628
[Parameter(Mandatory = $true)]
27-
[string] $AppPrivateKeySecretName,
29+
[ValidateNotNullOrEmpty()]
30+
[string] $AppIdSecretName,
2831

2932
# Login of the organization or user account whose installation we should
3033
# mint the token for (e.g. `dotnet`, `microsoft`).
@@ -51,55 +54,33 @@ function ConvertTo-Base64Url([byte[]] $bytes) {
5154
return [Convert]::ToBase64String($bytes).TrimEnd('=').Replace('+', '-').Replace('/', '_')
5255
}
5356

57+
Write-Host "Reading GitHub App ID from secret '$AppIdSecretName' in vault '$KeyVaultName'..."
5458
$previousNativeCommandErrorPreference = $PSNativeCommandUseErrorActionPreference
5559
try {
56-
# Azure CLI can emit non-fatal Python warnings to stderr.
5760
$PSNativeCommandUseErrorActionPreference = $false
58-
$keyVaultAccessToken = az account get-access-token `
61+
# az keyvault secret show fails for this projection with Errno 22; az rest keeps authentication in Azure CLI.
62+
$escapedSecretName = [Uri]::EscapeDataString($AppIdSecretName)
63+
$appId = az rest `
64+
--method get `
65+
--url "https://$KeyVaultName.vault.azure.net/secrets/${escapedSecretName}?api-version=7.4" `
5966
--resource https://vault.azure.net `
60-
--query accessToken `
67+
--query value `
6168
--output tsv `
6269
--only-show-errors
63-
$tokenExitCode = $LASTEXITCODE
70+
$secretExitCode = $LASTEXITCODE
6471
}
6572
catch {
66-
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to acquire an Azure Key Vault access token: $_"
73+
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to read App ID secret '$AppIdSecretName' from vault '$KeyVaultName' with Azure CLI: $_"
6774
exit 1
6875
}
6976
finally {
7077
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandErrorPreference
7178
}
72-
if ($tokenExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($keyVaultAccessToken)) {
73-
Write-PipelineTelemetryError -Category 'Build' -Message "'az account get-access-token' exited with code $tokenExitCode while acquiring an Azure Key Vault access token."
79+
if ($secretExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($appId)) {
80+
Write-PipelineTelemetryError -Category 'Build' -Message "'az rest' failed with exit code $secretExitCode while reading App ID secret '$AppIdSecretName' from vault '$KeyVaultName'. Verify the service connection can read this App-ID projection."
7481
exit 1
7582
}
7683

77-
function Get-KeyVaultSecret([string] $SecretName) {
78-
# Use the data-plane REST API because `az keyvault secret show` can fail
79-
# with Errno 22 on hosted Windows agents when reading these projections.
80-
$escapedSecretName = [Uri]::EscapeDataString($SecretName)
81-
$secretUri = "https://$KeyVaultName.vault.azure.net/secrets/$escapedSecretName`?api-version=7.4"
82-
try {
83-
$response = Invoke-RestMethod `
84-
-Uri $secretUri `
85-
-Headers @{ Authorization = "Bearer $keyVaultAccessToken" } `
86-
-Method Get
87-
}
88-
catch {
89-
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to read secret '$SecretName' from vault '$KeyVaultName': $_. Verify the secret exists and the service connection has 'Key Vault Secrets User' access to it."
90-
exit 1
91-
}
92-
if ([string]::IsNullOrWhiteSpace($response.value)) {
93-
Write-PipelineTelemetryError -Category 'Build' -Message "Secret '$SecretName' in vault '$KeyVaultName' is empty."
94-
exit 1
95-
}
96-
return [string] $response.value
97-
}
98-
99-
Write-Host "Reading GitHub App credentials from vault '$KeyVaultName'..."
100-
$appId = Get-KeyVaultSecret $AppIdSecretName
101-
$privateKey = Get-KeyVaultSecret $AppPrivateKeySecretName
102-
10384
# Build JWT header and payload. Use [ordered] hashtables so JSON
10485
# serialization is deterministic.
10586
$jwtHeader = [ordered]@{
@@ -125,23 +106,34 @@ finally {
125106
$sha256.Dispose()
126107
}
127108

128-
Write-Host 'Signing JWT with the GitHub App private key...'
129-
$rsa = [System.Security.Cryptography.RSA]::Create()
109+
$digestBase64 = [Convert]::ToBase64String($digestBytes)
110+
Write-Host "Signing JWT with key '$KeyName' in vault '$KeyVaultName'..."
111+
$previousNativeCommandErrorPreference = $PSNativeCommandUseErrorActionPreference
130112
try {
131-
$rsa.ImportFromPem($privateKey)
132-
$signatureBytes = $rsa.SignHash(
133-
$digestBytes,
134-
[System.Security.Cryptography.HashAlgorithmName]::SHA256,
135-
[System.Security.Cryptography.RSASignaturePadding]::Pkcs1)
136-
$signatureUrl = ConvertTo-Base64Url $signatureBytes
113+
# Azure CLI can emit non-fatal Python warnings to stderr.
114+
$PSNativeCommandUseErrorActionPreference = $false
115+
$signatureBase64 = az keyvault key sign `
116+
--vault-name $KeyVaultName `
117+
--name $KeyName `
118+
--algorithm RS256 `
119+
--digest $digestBase64 `
120+
--query signature `
121+
--output tsv `
122+
--only-show-errors
123+
$signExitCode = $LASTEXITCODE
137124
}
138125
catch {
139-
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to sign the GitHub App JWT with the supplied private key: $_"
126+
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to sign the JWT via Key Vault (key '$KeyName', vault '$KeyVaultName'): $_. Verify the service connection has the Sign action on the key."
140127
exit 1
141128
}
142129
finally {
143-
$rsa.Dispose()
130+
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandErrorPreference
131+
}
132+
if ($signExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($signatureBase64)) {
133+
Write-PipelineTelemetryError -Category 'Build' -Message "'az keyvault key sign' exited with code $signExitCode for key '$KeyName' in vault '$KeyVaultName'. Verify the service connection has the Sign action on the key."
134+
exit 1
144135
}
136+
$signatureUrl = $signatureBase64.Trim().TrimEnd('=').Replace('+', '-').Replace('/', '_')
145137
$jwt = "$signingInput.$signatureUrl"
146138

147139
$headers = @{
@@ -198,6 +190,11 @@ catch {
198190
exit 1
199191
}
200192

193+
if ([string]::IsNullOrWhiteSpace($tokenResponse.token)) {
194+
Write-PipelineTelemetryError -Category 'Build' -Message "GitHub returned an empty installation token for '$InstallationOwner'."
195+
exit 1
196+
}
197+
201198
Write-Host "Got installation token for '$InstallationOwner' (expires $($tokenResponse.expires_at))."
202199
if ($OutputVariableName) {
203200
Write-Host "Setting pipeline variable '$OutputVariableName'."

‎eng/common/core-templates/job/onelocbuild.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ parameters:
1212
GitHubAppServiceConnection: 'dnceng-oneloc-githubapp'
1313
GitHubAppKeyVaultName: 'EngKeyVault'
1414
GitHubAppIdSecretName: 'oneloc-localization-app-app-id'
15-
GitHubAppPrivateKeySecretName: 'oneloc-localization-app-app-private-key'
15+
GitHubAppKeyName: 'oneloc-localization-app-key'
1616

1717
SourcesDirectory: $(System.DefaultWorkingDirectory)
1818
CreatePr: true
@@ -101,7 +101,7 @@ jobs:
101101
azureSubscription: ${{ parameters.GitHubAppServiceConnection }}
102102
keyVaultName: ${{ parameters.GitHubAppKeyVaultName }}
103103
appIdSecretName: ${{ parameters.GitHubAppIdSecretName }}
104-
appPrivateKeySecretName: ${{ parameters.GitHubAppPrivateKeySecretName }}
104+
keyName: ${{ parameters.GitHubAppKeyName }}
105105
installationOwner: ${{ parameters.GitHubOrg }}
106106
outputVariableName: 'GitHubAppInstallationToken'
107107
condition: ${{ parameters.condition }}

0 commit comments

Comments
 (0)