0

I have implemented OpenPGP encryption on a c# console application that sends out a PGP encrypted email, using MimeKit and Gpg4win. I have the console app running fine, but when I implement this for a Website running in IIS the public keys are not found. I receive an error like this:

MimeKit.Cryptography.PublicKeyNotFoundException: The public key could not be found.
  at MimeKit.Cryptography.OpenPgpContext.GetPublicKey(MailboxAddress mailbox)
  at MimeKit.Cryptography.OpenPgpContext.GetPublicKeys(IEnumerable`1 mailboxes)
  at MimeKit.Cryptography.OpenPgpContext.Encrypt(IEnumerable`1 recipients, Stream content)
  at MimeKit.Cryptography.MultipartEncrypted.Create(OpenPgpContext ctx, IEnumerable`1 recipients, MimeEntity entity)

I'm pretty sure this is only working in my console app because I'm running it under my User profile, and Gpg4win has my public keys stored under my profile application data i.e. in C:\Documents and Settings\me\Application Data\gnupg\

How can I allow my website, which is running under a specific app pool profile, to access these keys?

Thanks in advance

user806982
  • 135
  • 4
  • 16

1 Answers1

0

By default, the identity of the application pool is set to Application Pool identity, a virtual account, which has restricted access and is not ideal in such scenarios.

Create another account and give this access and necessary permissions on the public keys and then use this account as the application pool identity.

Kaushal Kumar Panday
  • 2,329
  • 13
  • 22