Page 1 of 1

How to generate gpg signed message using PHP

Posted: Wed Apr 18, 2007 11:17 am
by Vishal Bhurangi
Hi,
I am not able to generate gpg signed message using php. I am issuing following command to generate message

$respons=exec("/usr/bin/gpg --homedir ~/.gnupg --yes --batch -u PLANETHIPPO --passphrase-file pf.txt --status-fd 1 --clearsign --force-v3-sigs /home/planet/public_html/msg2.txt", $res);

In my appache error log I am getting error message

gpg: /home/planet/public_html/msg2.asc: clearsign failed: secret key not available


Please help me.

Thanks & Regards,
Vishal

Posted: Wed Apr 18, 2007 11:21 am
by John Cartwright
This is a long shot, but I think your pass phrase file is not being found. Are you sure pf.txt exists and you are pointing to it correctly?

Posted: Wed Apr 18, 2007 11:31 am
by RobertGonzalez
Does that command work at the CLI?

Posted: Thu Apr 19, 2007 12:13 am
by Vishal Bhurangi
Hi
Thanks for your reply.

Same command is working without any error or warning from Linux shell prompt.

Regards,
Vishal

Posted: Thu Apr 19, 2007 12:49 am
by Chris Corbyn
Vishal Bhurangi wrote:Hi
Thanks for your reply.

Same command is working without any error or warning from Linux shell prompt.

Regards,
Vishal

From the same directory the script is in?

EDIT | Make sure the web user (www-data, apache, or nobody or some other user) has access to read the relevant files.

Posted: Thu Apr 19, 2007 1:47 am
by jmut
$respons=exec("/usr/bin/gpg --homedir ~/.gnupg --yes --batch -u PLANETHIPPO --passphrase-file pf.txt --status-fd 1 --clearsign --force-v3-sigs /home/planet/public_html/msg2.txt", $res);
I think this "--homedir ~/.gnupg " is the key to your problem. In php you are probably not running as same user as from cli, hence leading to different directories.