通过Web浏览器进行Gpg加密 [英] Gpg encryption over web browser
问题描述
我有一个在Windows上运行的Web应用程序和用Perl写的IIS。
其中一个脚本来自多个任务。其中一个执行命令加密文件。这是命令:
我的$ cmd =c:\\gnupg\\pub\\ gpg -ase --always-trust --batch --passphrase mypassphrase --output $ filename.pgp -r stuff $ filename;
qx / $ cmd /;
不幸的是,这不行。
我得到的错误是:
gpg:没有默认密钥:没有密钥gpg:C:\ \Dev\\somefile.csv:sign + encrypt failed:没有密钥
当我我试图在同一台服务器上运行相同的命令,它的工作正常。
根据我的理解,当您通过网络运行scrip时,它以匿名用户身份运行。所以它看不到作为本地用户生成的secrey密钥。如果我通过cmd在本地运行命令,它会看到秘密密钥,因为它作为本地用户运行。
问题是:我该如何解决这个问题,工作?
谢谢,
-Andrey
我最终确定了如何解决这个问题。
我做的是:
1.输出公共和秘密键作为本地用户。
2.使用web perl脚本导入公共密钥。
我的$ cmd =c:\gnupg\pub\gpg --import c :\public.key;
qx / $ cmd /;
3.同样输入密钥。
我必须为每个密钥运行一次脚本,以便为Web服务器用户创建密钥。
之后,我的应用程序开始正常工作!
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
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!
这篇关于通过Web浏览器进行Gpg加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!