question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE REQ] Support zero-touch certificate rotation in ClientCertificateCredential

See original GitHub issue

Library or service name. Azure.Identity

Is your feature request related to a problem? Please describe. In our service, certificates are retrieved from KeyVault. We use SNI authentication. Certificates can be rotated at any time while the service is running and we want zero-touch certificate rotation. i.e. you shouldn’t have to restart the app just because certificates have been rotated. Rather, the service should periodically go back to Key Vault and, if there’s a new version, the service should automatically pick it up and use it when OAuth tokens expire. We have a (self-imposed) 4 hour SLA for responding to certificate rotation events and renewing tokens.

To do this, we wrote custom code in a class derived from TokenCredential that implements both SNI and certificate refresh. To implement certificate refresh, we introduced a ICertificateProvider interface. This is similar to the internal ClientCertificateCredential.IX509Certificate2Provider interface, but it is used not only for constructing the ConfidentialClientApplication, but also inside AcquireTokenForClientAsync.

My proposal is:

  1. Un-nest IX509Certificate2Provider and make it public:
namespace Azure.Identity
{
    public interface IX509Certificate2Provider
    {
        ValueTask<X509Certificate2> GetCertificateAsync(bool async, CancellationToken cancellationToken);
    }
}
  1. Add a constructor overload on ClientCertificateCredential that accepts an IX509Certificate2Provider:
        public ClientCertificateCredential(string tenantId, string clientId, IX509Certificate2Provider certificateProvider, ClientCertificateCredentialOptions options);
  1. Update MsalConfidentialClient to call GetCertificateAsync each time AcquireTokenForClientAsync is called and cache the resulting X509Certificate2 object. If the value changes (due to a certificate refresh), then the confidential client needs to be recreated or updated. This part is tricky, I realize – but that’s why I’d like the SDK to take care of it for us.

You do have to be clear about the semantics of IX509Certificate2Provider since certificates are IDisposable – does the caller take ownership of the returned certificate, for example?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
degantcommented, Jul 27, 2022

Any update on the original ask of making IX509Certificate2Provider public as well as the new ctor on ClientCertificateCredential?

A bunch of services we own will benefit from this i.e being able to dynamically retrieve and use new certs from KV periodically without restarting the app.

0reactions
christothescommented, Mar 14, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Configure certificate auto-rotation in Key Vault
Tutorial showing how to update a certificate's auto-rotation frequency in Azure Key Vault using the Azure portal.
Read more >
Zero Touch Provisioning - Thingstream Documentation
The solution provides an out-of-the-box, simple and cost effective way to provision over-the air and securely digital certificates and private key in the...
Read more >
Rotate Citrix Cloud SAML signing certificate used by Azure ...
This is an example of the error you may encounter when logging into Citrix Workspace or Citrix Cloud. Error: No certificate matching provided...
Read more >
How to Rotate your External IdP Certificates in AWS IAM ...
As announced in May 2020, you can now rotate the X.509 certificates they use for external identity providers (IdPs) with zero authentication downtime...
Read more >
How to Automatically Rotate AAD Application Certificates
With the exponential growth of online services, it has become impossible to manually rotate application certificates.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found