Skip to content

Fix losing certificates for credentials with CredentialSource.Certificate#3711

Open
pentp wants to merge 1 commit intoAzureAD:masterfrom
pentp:fix-null-certs
Open

Fix losing certificates for credentials with CredentialSource.Certificate#3711
pentp wants to merge 1 commit intoAzureAD:masterfrom
pentp:fix-null-certs

Conversation

@pentp
Copy link

@pentp pentp commented Feb 5, 2026

DefaultCertificateLoader.ResetCertificates incorrectly resets certificates for CredentialSource.Certificate which causes extremely confusing and hard to debug errors about null certificates later.
Also cleaned up a bit of redundant code.

@pentp pentp requested a review from a team as a code owner February 5, 2026 21:08

if (credentialDescription.CachedValue == null)
if (credentialDescription.CachedValue == null
&& (credentialDescription.SourceType == CredentialSource.CustomSignedAssertion || CredentialSourceLoaders.ContainsKey(credentialDescription.SourceType)))
Copy link
Member

Choose a reason for hiding this comment

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

@pentp - can you please explain why this was done?

Copy link
Author

Choose a reason for hiding this comment

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

This is principally for CredentialSource.Certificate - it doesn't have an associated loader and its CachedValue will always be null, so this just skips the semaphore setup and locking entirely.

{
foreach (var credentialDescription in credentialDescriptions)
{
credentialDescription.CachedValue = null;
Copy link
Member

Choose a reason for hiding this comment

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

I think we would need unit tests.

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.

2 participants