开发者

Gpg encryption over web browser

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 --passphras开发者_StackOverflowe 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!


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/;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜