views:

375

answers:

2

Hi! Trying to use GnuPG with Delphi (Win32). I need to sign some file with such console command:

"C:\Program Files\GNU\GnuPG\gpg.exe" -a -u Alex --passphrase secretpassword --yes --clearsign -o C:\Result.asc C:\InputFile.txt

First I created normal VCL Forms App and used CreateProcess function, everything was OK, but when I transfered that code to my service app, gpg.exe exits with code 2. Maybe I missed something? Any ideas?

Update

Just in case someone has such a problem. GnuPG stores keys in C:\Documents And Settings\<username>\Application Data\gnupg\ but when service runs from another user account (SYSTEM) - it can't find your key. GL & HF

+2  A: 

Try dumping stderr and see if you get anything. You may be able to pipe the message in. It could be a problem reading the passphrase. I sort of remember having to pipe the passphrase into gpg instead of specifying it as a parameter.

sybreon
Yep, that was pretty much it. I got 'clearsign failed: secret key not available' from stdErr...
Thanks for your advice. Please, see "Update". Thanks!
Then you've got to specify `--home` as well.
sybreon
A: 

As a (child of a) service app, there is no shell as parent, so the child apps might simply be unable to use stdio. Attempt to execute with cmd /c or via shellexecute. Or better, use a program that doesn't always require stdio.

Marco van de Voort