From ece43792a8335393a3611d1e9ad529edd7b7501c Mon Sep 17 00:00:00 2001 From: "Michael J. Lyons (XBOX)" Date: Thu, 18 Jul 2024 06:18:56 -0700 Subject: [PATCH] Debugging updates --- .../Core/Authentication/MicrosoftAuthentication.cs | 12 +++--------- .../Microsoft.AzureRepos/AzureReposHostProvider.cs | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/shared/Core/Authentication/MicrosoftAuthentication.cs b/src/shared/Core/Authentication/MicrosoftAuthentication.cs index c64ce4b9c..12bccf5fe 100644 --- a/src/shared/Core/Authentication/MicrosoftAuthentication.cs +++ b/src/shared/Core/Authentication/MicrosoftAuthentication.cs @@ -274,20 +274,14 @@ public async Task GetTokenForServicePrincipalAsy try { - var tokenBuilder = app.AcquireTokenForClient(scopes); - - if (sp.SendX5C) - { - tokenBuilder = tokenBuilder.WithSendX5C(true); - } - - AuthenticationResult result = await tokenBuilder.ExecuteAsync(); + Context.Trace.WriteLine($"Sending with X5C: '{sp.SendX5C}'."); + AuthenticationResult result = await app.AcquireTokenForClient(scopes).WithSendX5C(sp.SendX5C).ExecuteAsync();; return new MsalResult(result); } catch (Exception ex) { - Context.Trace.WriteLine($"Failed to acquire token for service principal '{sp.TenantId}/{sp.TenantId}'."); + Context.Trace.WriteLine($"Failed to acquire token for service principal '{sp.TenantId}/{sp.Id}'."); Context.Trace.WriteException(ex); throw; } diff --git a/src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs b/src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs index cdbf16133..9bd6c72a1 100644 --- a/src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs +++ b/src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs @@ -555,7 +555,7 @@ private bool UseServicePrincipal(out ServicePrincipalIdentity sp) AzureDevOpsConstants.GitConfiguration.Credential.ServicePrincipalCertificateSendX5C, out string certHasX5C); - sp.SendX5C = !hasX5CSetting || certHasX5C == "false"; + sp.SendX5C = !hasX5CSetting || certHasX5C != "false"; X509Certificate2 cert = X509Utils.GetCertificateByThumbprint(certThumbprint); if (cert is null)