SecureRequest.AzureKeyVault
1.1.0
dotnet add package SecureRequest.AzureKeyVault --version 1.1.0
NuGet\Install-Package SecureRequest.AzureKeyVault -Version 1.1.0
<PackageReference Include="SecureRequest.AzureKeyVault" Version="1.1.0" />
<PackageVersion Include="SecureRequest.AzureKeyVault" Version="1.1.0" />
<PackageReference Include="SecureRequest.AzureKeyVault" />
paket add SecureRequest.AzureKeyVault --version 1.1.0
#r "nuget: SecureRequest.AzureKeyVault, 1.1.0"
#:package SecureRequest.AzureKeyVault@1.1.0
#addin nuget:?package=SecureRequest.AzureKeyVault&version=1.1.0
#tool nuget:?package=SecureRequest.AzureKeyVault&version=1.1.0
SecureRequest.AzureKeyVault
Azure Key Vault integration for the SecureRequest NuGet package.
Two modes are available — choose based on your security requirements:
| Mode | Private key in memory? | Decryption | When to use |
|---|---|---|---|
Secrets (.WithAzureKeyVault) |
✅ Yes (loaded at startup) | In-process | Centralised key storage, audit logging |
True HSM (.WithAzureKeyVaultHsm) |
❌ Never | Azure Key Vault | PCI-DSS, HIPAA, FIPS 140-2/3, zero-export |
Installation
dotnet add package SecureRequest
dotnet add package SecureRequest.AzureKeyVault
Mode 1 — Secrets (private key stored as a Key Vault secret)
The RSA private key is generated locally, stored as an Azure Key Vault secret, and loaded into memory at startup. Key Vault provides encrypted-at-rest storage, RBAC access control, and full audit logging.
builder.Services
.AddSecureRequest(builder.Configuration)
.WithAzureKeyVault("https://your-vault.vault.azure.net/");
DefaultAzureCredential is used automatically — works with Managed Identity in Azure, and falls back to Azure CLI / Visual Studio / environment variables in development.
Custom secret name and credential
builder.Services
.AddSecureRequest(builder.Configuration)
.WithAzureKeyVault(
keyVaultUri : "https://your-vault.vault.azure.net/",
secretName : "MyApp-RsaPrivateKey",
credential : new ClientSecretCredential(tenantId, clientId, clientSecret));
Required permissions (Secrets mode)
| Operation | Azure RBAC role |
|---|---|
| Read secret | Key Vault Secrets User |
| Write secret | Key Vault Secrets Officer |
Mode 2 — True HSM (private key never leaves Key Vault)
The RSA key pair lives entirely inside Azure Key Vault (or a Managed HSM). The private key never enters application memory. Decryption is delegated to Key Vault's Decrypt API — one Key Vault call per secured request.
Prerequisites
- Create an RSA key (type: RSA or RSA-HSM) in Key Vault with the
decryptoperation enabled. - Assign the identity running the app the following RBAC roles:
Key Vault Crypto User— allowsGetKeyandDecrypt- (Optional)
Key Vault Crypto Service Encryption User— for audit compliance
Registration
builder.Services
.AddSecureRequest(builder.Configuration)
.WithAzureKeyVaultHsm(
keyVaultUri : "https://your-vault.vault.azure.net/",
keyName : "secure-request-rsa-key");
In production, prefer ManagedIdentityCredential for a smaller, faster credential chain:
builder.Services
.AddSecureRequest(builder.Configuration)
.WithAzureKeyVaultHsm(
keyVaultUri : "https://your-vault.vault.azure.net/",
keyName : "secure-request-rsa-key",
credential : new ManagedIdentityCredential());
How it works
- Startup —
AzureKeyVaultHsmInitializerServicecallsKeyClient.GetKeyAsync(), extracts the public key from the JSON Web Key (N+E), and loads it intoRsaKeyProvider.LoadPublicKeyOnly(). The/api/secure/public-keyendpoint returns this key. - Per request —
AzureKeyVaultDecryptProvidersends the encrypted AES secret toCryptographyClient.DecryptAsync(RsaOaep256, ...)and receives the plaintext. The private key never exits Key Vault. - No local storage —
MemoryKeyStorageProvideris used automatically; no Redis or Key Vault secret is needed for key storage.
Note:
IDistributedCacheis still required for nonce anti-replay storage. Only the decryption path moves to Key Vault — nonces remain in Redis/in-memory cache.
appsettings.json
No additional configuration needed — SecureRequest options are bound from the same section:
"SecureRequest": {
"Enabled": true,
"EnableBodyEncryption": true,
"EnableHmacSigning": true,
"TimestampToleranceSeconds": 300,
"NonceCacheTtlSeconds": 700,
"SecuredMethods": ["POST", "PUT", "PATCH"],
"ExcludedPaths": []
}
Comparison
| Default (Redis) | Secrets mode | True HSM mode | |
|---|---|---|---|
| Key stored in | Redis (Base64) | Key Vault (encrypted) | Key Vault HSM (non-exportable) |
| Private key in memory | ✅ | ✅ | ❌ |
| Access control | Redis auth | Azure RBAC | Azure RBAC |
| Audit trail | None | Key Vault logs | Key Vault logs |
| FIPS 140-2/3 compliant | No | No | Yes (RSA-HSM key type) |
| Latency per request | Negligible | Negligible | +1 Key Vault API call |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Azure.Identity (>= 1.21.0)
- Azure.Security.KeyVault.Keys (>= 4.6.0)
- Azure.Security.KeyVault.Secrets (>= 4.6.0)
- SecureRequest (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 64,767 | 6/12/2026 |