Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Debugging updates
  • Loading branch information
Michael J. Lyons (XBOX) committed Jul 18, 2024
commit ece43792a8335393a3611d1e9ad529edd7b7501c
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

This comment was marked as outdated.

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