Delphi 服务中的 GnuPG 和 CreateProcess
尝试将 GnuPG 与 Delphi (Win32) 一起使用。 我需要使用这样的控制台命令签署一些文件:
"C:\Program Files\GNU\GnuPG\gpg.exe" -a -u Alex --passphrase Secretpassword --yes --clearsign -o C:\Result.asc C:\InputFile.txt
首先,我创建了普通的 VCL Forms 应用程序并使用了 CreateProcess
函数,一切正常,但是当我将该代码传输到我的服务应用程序时,gpg.exe 退出并显示代码 2。也许我错过了什么? 有任何想法吗?
更新
以防万一有人遇到这样的问题。 GnuPG 将密钥存储在 C:\Documents And Settings\
中,但是当服务从另一个用户帐户 (SYSTEM) 运行时 - 它找不到您的密钥。 总帐及 高频
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试转储 stderr 并查看是否得到任何结果。 您也许可以通过管道输入消息。读取密码短语可能出现问题。 我记得必须将密码通过管道传输到 gpg 中,而不是将其指定为参数。
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.
作为服务应用程序(的子应用程序),没有 shell 作为父应用程序,因此子应用程序可能根本无法使用 stdio。 尝试使用 cmd /c 或通过 shellexecute 执行。 或者更好的是,使用并不总是需要 stdio 的程序。
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.