|
Posted by cyclops on 02/03/06 05:41
(excuse the double posting, I sent my first one as a reply accidentaly...)
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...
[Back to original message]
|