How to generate gpg signed message using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Vishal Bhurangi
Forum Newbie
Posts: 2
Joined: Wed Apr 18, 2007 11:09 am

How to generate gpg signed message using PHP

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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?
Last edited by John Cartwright on Wed Apr 18, 2007 11:50 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Does that command work at the CLI?
Vishal Bhurangi
Forum Newbie
Posts: 2
Joined: Wed Apr 18, 2007 11:09 am

Post by Vishal Bhurangi »

Hi
Thanks for your reply.

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

Regards,
Vishal
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post 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.
Post Reply