You are here: GPG with PHP (using PECL gnupg extension « All PHP « IT news, forums, messages
GPG with PHP (using PECL gnupg extension

Posted by cyclops on 02/03/06 05:39

I need to be able to use public key encryption with php on a
linux/apache machine. gpg is installed and running properly, and I could
use something like

shell_exec("echo $argv[1] | $gpg -e -r $recipient"));

but that would expose too much information via ps, so the solution seems
to be using the PECL gnupg extensions. However, I can't seem to get it
to work. I've installed the extension enough that it recognizes the
functions, but I can't use them.

Examples of my problem:
1)
<?
$res = gnupg_init();
$info = gnupg_keyinfo($res,<valid-gpg-name>);
print_r($info);
?>
returns an empty array.
----------------------------
2)
<?
$keydata = "-----BEGIN PGP PUBLIC KEY BLOCK-----
....abreviated...
-----END PGP PUBLIC KEY BLOCK-----";

$res = gnupg_init();
$info = gnupg_import($res,$keydata);
print_r($info);
?>
returns:
Array ( [imported] => 0 [unchanged] => 0 [newuserids] => 0 [newsubkeys]
=> 0 [secretimported] => 0 [secretunchanged] => 0 [newsignatures] => 0
[skippedkeys] => 0 )
----------------------------

In essence, I'm pretty sure that php can't access the keyring. I've read
somewhere that I need to set the GNUPGHOME environment variable to the
..gnupg directory, but that doesn't seem to work.

Also, permission are probably an issue. The user I used to create the
keyring (with gpg --gen-key) is not the same as the user that runs
apache (which is beyond my control at this point, and set to nobody, and
has no shell, so I couldn't even su into it).

Any pointers? Anything I should look at? I'm out of ideas for today...

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация