GPG key import through PHP not working (works in shell)
I have to import a GPG key in a PHP script, it works using the command 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 Ubuntu 9.10 Server with GnuPG 1.4.9, PHP 5.2.6.
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 ?
精彩评论