PHP gnupg 'import failed'

做~自己de王妃 提交于 2019-12-10 15:44:13

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/30768968/php-gnupg-import-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!