通过网络浏览器进行 Gpg 加密

发布于 2024-11-27 21:45:27 字数 641 浏览 4 评论 0原文

我在网上搜索过,但找不到答案,所以我希望能在这里找到答案。

我有一个在 Windows 上运行的 Web 应用程序和用 Perl 编写的 IIS。 其中一个脚本执行多项任务。其中之一执行命令来加密文件。命令如下:

my $cmd = "c:\\gnupg\\pub\\gpg -ase --always-trust --batch --passphrase mypassphrase --output $filename.pgp -r stuff $filename";

qx/$cmd/;

不幸的是,这不起作用。 我得到的错误是:

gpg: no default secret key: No secret key gpg: C:\\Dev\\somefile.csv: sign+encrypt failed: No secret key

当我尝试从 cmd 在同一服务器上运行相同的命令时,它工作正常。

据我了解,当您通过网络运行脚本时,它会以匿名用户身份运行。因此它看不到作为本地用户生成的密钥。如果我通过 cmd 在本地运行该命令,它会看到密钥,因为它以本地用户身份运行。

问题是:如何解决这个问题并使票据发挥作用?

谢谢你,

-安德烈

I have search all over the web, but unable to find an answer, so I hope I can find one here.

I have a web application run on Windows and IIS written in Perl.
One of the scripts perfroms multiple tasks. One of them executes a command to encrypt a file. Here is the command:

my $cmd = "c:\\gnupg\\pub\\gpg -ase --always-trust --batch --passphrase mypassphrase --output $filename.pgp -r stuff $filename";

qx/$cmd/;

Unfortunately, this does not work.
The error I get is:

gpg: no default secret key: No secret key gpg: C:\\Dev\\somefile.csv: sign+encrypt failed: No secret key

When I am trying to run same command on same server from cmd it works fine.

From what I understand, when you run a scrip through web, it runs as anonymous user. So it does not see the secrey key generated as a local user. If I run the command locally through cmd it sees the secret key since it runs as a local user.

The question is: how do I solve this problem and make the scrip work?

Thank you,

-Andrey

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

丑丑阿 2024-12-04 21:45:27

我终于想出了如何解决这个问题。
我的做法是:
1. 以本地用户身份导出公钥和私钥。
2. 使用 web perl 脚本导入公钥。
我的 $cmd = "c:\gnupg\pub\gpg --import c:\public.key";
qx/$cmd/;
3. 执行相同的操作来导入密钥。

我必须为每个密钥运行一次脚本,以便为 Web 服务器用户创建密钥。
之后我的应用程序开始完美运行!

I FINALLY figured out how to solve this problem.
The way I did it was:
1. Export both public and secret keys as a local user.
2. Import public key using web perl script.
my $cmd = "c:\gnupg\pub\gpg --import c:\public.key";
qx/$cmd/;
3. Do same to inport the secret key.

I have to run the script once for each key so that the keys are created for web server user.
After that my application started to worked flawlessly!

给不了的爱 2024-12-04 21:45:27

您可以在启动命令之前使用 GNUPGHOME 环境变量。

GNUPGHOME=C:\\Users\\myUser\\.gnupg\\ 
my $cmd = "c:\\gnupg\\pub\\gpg -ase --always-trust --batch --passphrase mypassphrase --output $filename.pgp -r stuff $filename";

qx/$cmd/;

You can use the GNUPGHOME environnement variable instead before launching your command.

GNUPGHOME=C:\\Users\\myUser\\.gnupg\\ 
my $cmd = "c:\\gnupg\\pub\\gpg -ase --always-trust --batch --passphrase mypassphrase --output $filename.pgp -r stuff $filename";

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