I a am trying to encrypt a string while running an application as self hosted using DataProtectionProvider. I then need to decrypt the string while the same application is hosted in IIS. I have found that this does not work. I get a cryptographicException 'the key {} was not found in the key ring' when i try to unprotect a key that was protected while self hosted or in IIS Express in IIS.
I have experimented with the options when registering the data protection and ensured the application name and purpose are the same. Self hosted and IIS Express appear to use the same key, while IIS uses another key.
Does anybody know how I can force the self hosted instance to use the same key as the ISS instance?
I'm developing and deploying to a secure offline environment so cant use redis or azure key vault.
I'm struggling to find a solution online so hope that somebody knows a way to get around this.
Thanks
Paul