收到“GPG 错误”将 Java 应用程序作为 Windows 7 服务运行时
当我使用包装器将 Java 应用程序作为 Windows 服务运行时,一切正常,除非应用程序尝试解密文件。它会产生以下错误:
GPG错误>>代码:2>> gpg:使用RSA密钥加密,ID ########
gpg 解密失败:密钥不可用。
当不作为服务运行时,应用程序可以毫无问题地加密和解密文件。包装纸也工作得很好。
环境变量已在 Windows 注册表中设置并确认,但由于某种原因,系统不会在密钥所在的 Users\AppData\...
目录中查找。
这是一个自动化应用程序,因此没有用于加密或解密文件的密码。
怎么了?系统可能在哪里寻找密钥?
When I run my Java application as a Windows service utilizing a wrapper, everything works fine except when the application tries to decrypt a file. It produces the following error:
GPG error >> code: 2 >> gpg: encrypted with RSA key, ID ########
gpg decryption failed: secret key not available.
The application encrypts and decrypts files without any problem when not running as a service. The wrapper also works fine.
Environment variables were set and confirmed in the Windows registry, but for some reason the system doesn't look in the Users\AppData\...
directory where the key is located.
This is an automated application, so there is no passphrase to encrypt or decrypt files.
What is wrong? Where might the system be looking for a secret key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过更改服务属性解决了上述问题。我采取了以下步骤来解决问题。
在命令行中输入 services.msc,然后按 Enter 键。它将打开服务窗口。
找到我的服务,右键单击,然后单击属性
单击“登录”选项卡,然后单击“此帐户”单选按钮
单击“浏览”按钮,然后输入要选择的对象名称 我输入了计算机的用户名,然后单击“检查名称”按钮,一旦用户名确认,单击“确定”按钮
输入密码和确认密码,然后单击“应用”,单击“确定”通知对话框
停止服务,然后重新启动服务,发送加密文件,它会按应有的方式工作。
停止服务,然后
为什么我必须这样做,因为当我默认创建服务时,它使用本地系统帐户而不是所有密钥和配置文件所在的我的用户帐户。
现在的问题是或者有人喜欢回答:
如何更改或更改 Windows 操作系统中的本地系统帐户?
I resolved above problem by changing the service properties. Following step I took to resolve the problem.
On command line enter services.msc then hit Enter Key. It will open services window.
Locate my service and right click then click properties
Click on Log on Tab then click on this account radio button
Click on Browse button then Enter the object name to select I entered my username for my machine and click Check Name button once User name confirmed click Ok button
Enter Password and Confirm Password then click Apply click ok notice dialog box
Stop the service then restart the service sends encrypted files and it works as it should be.
Why I have to do this because when I created service by default it is uses Local System account not my user account where all the keys and profile located.
Now question is or someone likes to answer:
How to alter or change Local System account in Windows OS?
将密钥环添加到 C:\Users\Default\AppData\Roaming\gnupg 文件夹中。显然本地系统帐户从这里获取密钥环。
Add your keyring to your C:\Users\Default\AppData\Roaming\gnupg folder. Apparently the localsystem account grabs the keyring from here.