Share via


DefaultCertificateLoader Class

Definition

Certificate Loader. Only use when loading a certificate from a daemon application, or an ASP NET app, using MSAL .NET directly. For an ASP NET Core app, Microsoft Identity Web will handle the certificate loading for you.

IConfidentialClientApplication app;
ICertificateLoader certificateLoader = new DefaultCertificateLoader();
    certificateLoader.LoadIfNeeded(config.CertificateDescription);

   app = ConfidentialClientApplicationBuilder.Create(config.ClientId)
          .WithCertificate(config.CertificateDescription.Certificate)
          .WithAuthority(new Uri(config.Authority))
          .Build();
public class DefaultCertificateLoader : Microsoft.Identity.Web.DefaultCredentialsLoader, Microsoft.Identity.Web.ICertificateLoader
type DefaultCertificateLoader = class
    inherit DefaultCredentialsLoader
    interface ICertificateLoader
Public Class DefaultCertificateLoader
Inherits DefaultCredentialsLoader
Implements ICertificateLoader
Inheritance
DefaultCertificateLoader
Implements

Constructors

DefaultCertificateLoader()

Default constuctor.

DefaultCertificateLoader(ILogger<DefaultCertificateLoader>)

Constructor with a logger.

Properties

CredentialSourceLoaders

Dictionary of credential loaders per credential source. The application can add more to process additional credential sources(like dSMS).

(Inherited from DefaultCredentialsLoader)
UserAssignedManagedIdentityClientId

This default is overridable at the level of the credential description (for the certificate from KeyVault).

Methods

LoadAllCertificates(IEnumerable<CertificateDescription>)

Load all the certificates from the certificate description list.

LoadCredentialsIfNeededAsync(CredentialDescription, CredentialSourceLoaderParameters)

Load a given credential description, if needed. This method will leverage the CredentialSourceLoaders to load the credentials from the description.

(Inherited from DefaultCredentialsLoader)
LoadFirstCertificate(IEnumerable<CertificateDescription>)

Load the first certificate from the certificate description list.

LoadFirstCertificateAsync(IEnumerable<CertificateDescription>)

Load the first certificate from the certificate description list.

LoadFirstValidCredentialsAsync(IEnumerable<CredentialDescription>, CredentialSourceLoaderParameters)

Load the first valid credential from the credentials description list. This is useful when you have multiple deployments (for instance on your developer machine, you can use a certificate from KeyVault, and when deployed in AKS, you use workload identity federation for AKS. You can express the list of credentials in the appsettings.json file, and this method will load the most appropriate based on the order.

(Inherited from DefaultCredentialsLoader)
LoadIfNeeded(CertificateDescription)

Load the certificate from the description, if needed.

LoadIfNeededAsync(CertificateDescription)

Load the certificate from the description, if needed.

ResetCertificates(IEnumerable<CertificateDescription>)

Resets all the certificates in the certificate description list. Use, for example, before a retry.

ResetCertificates(IEnumerable<CredentialDescription>)

Resets all the certificates in the certificate description list. Use, for example, before a retry.

ResetCredentials(IEnumerable<CredentialDescription>)

Resets resettable credentials in the credential description list (for instance reset the certificates so that they can be re-loaded again) Use, for example, before a retry.

(Inherited from DefaultCredentialsLoader)

Applies to