Skip to content

Commit

Permalink
Debugging updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael J. Lyons (XBOX) committed Jul 18, 2024
1 parent 62b9c3d commit ece4379
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions src/shared/Core/Authentication/MicrosoftAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,14 @@ public async Task<IMicrosoftAuthenticationResult> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ece4379

Please sign in to comment.