views:

190

answers:

1

Hello, I have to import a GPG key in a PHP script, it works using the commande line

gpg --import "/home/me/pubkey.txt"

but does not work using the PHP gpg class with the import method even with the gnupg_import function.

My configuration is :

  • RedHat Enterprise Linux 5
  • PHP 5.1.6
  • GnuPG 1.4.5
  • GPGme 1.1.8
  • GPG extension 1.3.1

I also tried using the exec or system functions of PHP, but with no success, with the same command line (exec('cat "/home/me/pubkey.txt"') works so the file is readable).

Edit: It works on Unbuntu 9.10 Server with GnuPG 1.4.9, PHP 5.2.6.

+1  A: 

Got it ! I am the one who had the problem, Fabien posted this question on SO.

It's a file permission issue : it tried to write in the .gnupg file on /root (the HOME env var) but PHP can't write in it.

We have to change the rights on this file so that PHP can write in it, or move this to a directory writeable by PHP.

What is the best solution ?

lryo