Delphi 服务中的 GnuPG 和 CreateProcess

发布于 2024-07-20 07:51:22 字数 638 浏览 2 评论 0原文

尝试将 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\\Application Data\gnupg\ 中,但是当服务从另一个用户帐户 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤星 2024-07-27 07:51:22

尝试转储 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.

反目相谮 2024-07-27 07:51:22

作为服务应用程序(的子应用程序),没有 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文