Azure key - using rsa (private and public key)



The idea is pretty simple, create a rsa key in azure. Use public key to encrypt. Then use private key to decrypt. Private key never leave the vault.

Here is the code for doing that.


If you're getting bad request? Please check to make sure you have added MSI to the keyvault access policy.


I had that many many times the following error message,

Unhandled Exception: Microsoft.Azure.KeyVault.Models.KeyVaultErrorException: Operation returned an invalid status code 'BadRequest'

and the problem is due to, specifying foAEP to false, instead of true.


var encryptedText = rsa.Encrypt(byteData, fOAEP: true); // use to be false :(

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm