Link to home
Start Free TrialLog in
Avatar of boxerbill
boxerbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Run gpg.exe from asp.net website

I have an ASP.NET website written in c#, that allows users to upload a file of names and addresses, to be imported into an SQL database.  The users need to supply the file in a GnuPG encrypted file, which is then automatically decrypted and then deleted after import.

Evary part of the process works on my Visual Studio 2008 development server but when I move it to the production environment, it all seams fine apart from the decryption.

The code I'm using is as follows:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.WorkingDirectory = TBRv2SVs.GnuPG;
System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);
string sCommandLine = "echo " + passphrase + "| gpg.exe --passphrase-fd 0 -o \"" + outputFileNameFullPath + "\" --decrypt \"" + encryptedFile.FullName + "\"";
process.StandardInput.WriteLine(sCommandLine);
process.StandardInput.Flush();
process.StandardInput.Close();
process.WaitForExit();
process.Close();

Open in new window

Avatar of Edgard Yamashita
Edgard Yamashita
Flag of Brazil image

does the asp.net/network users have write/read permission to the folder where the gpg is creating the decrypted file?
Hi,

System.Diagnostics.Process will not be supported in web application. (After configuring in IIS, it will not work). Try different kind of code.

http://www.codeguru.com/csharp/.net/net_security/pgp/article.php/c4699
Avatar of boxerbill

ASKER

Thanks eguilherme.  I've set read/write/modify permission for the local ASP.NET account and the anonymous access user account.  I have also set read remissions for both on the GnuPG executable folder.  IIS has been configured with Excecute permissions for both Scripts and Excecutable.  Still no joy.

Thanks also rajapandian 81 but that code only apears to have the capabilty to work on messages. I'm trying to decrypt files. I'm sure it's possible because it works on my development server.

I can't find any error messages anywhere to say why it's not working but everything seems to point to the lack of permission to actually run either the cmd.exe or gpg.exe command.
Have you tested from development server IIS ?
SOLUTION
Avatar of rajapandian_81
rajapandian_81
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial