Search code examples
delphiservicepgpgnupg

GnuPG and CreateProcess in Delphi Service


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


Solution

  • 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.