Closed toastmastern closed 2 years ago
Sounds like a good idea, i try to do the changes and come back but not sure when i got the time.
Added two properties on the Certificate object:
When UseMachineKeySet is true its only using the CertificateStream property to get the certificate.
Latest code uploaded and new nuget is on the way.
The SecureClient is Azure specific and i dont like to add that so this maybe can let you use SecureClient outside my class library and load it to stream.
Tried stream but with cloud its would perhaps be possible to simply add a "get from keyvault" instead to make it simpler and not require cert store on user account.
Snippet below might be of help? (this does not require a store to be opened) (if not perhaps have some kind of "skip open store and use X509KeyStorageFlags.MachineKeySet" as some kind of constructor params?)
public record CertificateSettings { public Uri? KeyVaultUri { get; init; } public string? Name { get; init; } }
private static X509Certificate2? GetCertificateFromKeyVault(CertificateSettings? certificate) { var secretClient = new SecretClient( certificate.KeyVaultUri, new DefaultAzureCredential() );
}
// in DI use this as httphandler