Reputation: 87
I have set-up Gpg4win on Windows Server 2008 R2 and the website is running .Net 4.5.
I'm using the Starksoft OpenPGP dll.
I've added the required public key to Gpg4win via remote desktop, however when testing in the browser I get the following in the browser:
gpg: [email protected]: skipped: No public key gpg: [stdin]: encryption failed: No public key
I've tested locally on my machine and directly in GPA and Kleopatra on the server and the encryption is working correctly. This leads me to believe that the issue is with the public key being set-up via remote desktop and not being accessible to the application pool or similar.
I've tried copying the pubring.gpg, secring.gpg and trustdb.gpg in to a protected subfolder of the website as suggested somewhere (I forget where now) but this has not worked.
Any ideas how to set-up the public keys to be accessible to the IIS user?
Upvotes: 1
Views: 7360
Reputation: 87
Research
Continued research lead me to this SO question: Gpg encryption over web browser which then lead me down the lines of running it via cmd - Running Command line from an ASPX page, and returning output to page
Solution
Create a page with the following code and execute it
System.Diagnostics.Process si = new System.Diagnostics.Process();
si.StartInfo.WorkingDirectory = "c:\\";
si.StartInfo.UseShellExecute = false;
si.StartInfo.FileName = "cmd.exe";
si.StartInfo.Arguments = "gpg --import c:\\public.key";
si.StartInfo.CreateNoWindow = false;
si.StartInfo.RedirectStandardInput = true;
si.StartInfo.RedirectStandardOutput = true;
si.StartInfo.RedirectStandardError = true;
si.Start();
string output = si.StandardOutput.ReadToEnd();
si.Close();
Upvotes: 2
Reputation: 14160
GnuPG looks for keyrings in user's home directory, and IIS is run by other user, most likely this is the reason. You can specify the exact path to public and secret keyrings via --keyring and --secret-keyring command line switches.
Upvotes: 1