I have been trying to use gnupg in PHP to encrypt a file that will be uploaded to an ftp folder. I am currently running on a mac using MAMP and I believe gnupg is installed correctly.
I have a 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 the cryptic 'import failed' message from gnupg.
$gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_EXCEPTION);
$gpg->import($key); //throws exception 'import failed'
Is there a better resource for reasons a key would fail to import?
Using GPG Suite, I can successfully import the key, so I believe the key is correct
You need to make sure that the program has read-write access rights to the pubring.gpg file. On my Linux Ubuntu 12.04.5 LTS this is located in my own ~/.gnupg directory. If not there, you may want to check the GNUPGHOME env. var.