Skip to content

Instantly share code, notes, and snippets.

@joonaszure
joonaszure / CreateAndValidateWithCertificates.cs
Created September 26, 2023 09:40
Using Azure Key Vault certificates for signing and encrypting JSON Web Tokens
var vaultUri = new Uri("https://your-key-vault.vault.azure.net/");
var credential = new AzureCliCredential(new AzureCliCredentialOptions
{
TenantId = "your-aad-tenant-id"
});
var certificateClient = new CertificateClient(vaultUri, credential);
static string GetKeyId(X509Certificate2 certificate)
{
@joonaszure
joonaszure / CreateAndValidateWithKeys.cs
Last active October 22, 2024 13:42
Using Azure Key Vault keys for signing and encrypting JSON Web Tokens
var vaultUri = new Uri("https://your-key-vault.vault.azure.net/");
var credential = new AzureCliCredential(new AzureCliCredentialOptions
{
TenantId = "your-aad-tenant-id"
});
var keyClient = new KeyClient(vaultUri, credential);
var cryptoProviderFactory = new CryptoProviderFactory();
cryptoProviderFactory.CustomCryptoProvider = new KeyVaultCryptoProvider(keyClient);