Gnupg import error in PHP?

I am trying to use gnupg in PHP to encrypt a file to be uploaded to an ftp folder. I am currently working on a mac using MAMP and I believe gnupg is installed correctly.

I have the public key from the recipient of the file, and when I try to import the key, either as a string literal or from a text file, I get an "import failed" error from gnupg.

$gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_EXCEPTION);
$gpg->import($key); //throws exception 'import failed'

      

Is there a better resource for reasons the key would not be able to import?

Using GPG Suite I can import the key successfully, so I believe the key is correct

+3


source to share


1 answer


You need to make sure that the program has read / write access to the pubring.gpg file. On my Linux Ubuntu 12.04.5 LTS, this is located in my own ~ / .gnupg directory. If not, you can check the GNUPGHOME env. var.



0


source







All Articles