问题描述
灵感来自 http://devzone.zend.com/1278/using-gnupg-with-php/并获得帮助@ PHP ASCII铠装PGP加密的字符串
Inspired by http://devzone.zend.com/1278/using-gnupg-with-php/ and with help @ PHP ASCII Armored PGP encrypted string
在CLI中运行时,我能够使用第三者公共密钥对字符串进行GnuPG加密.
I was able to GnuPG-encrypt a string with a 3rd party public key when running in CLI.
- 将GNUPGHOME设置为世界可读的位置
- 将chmod密钥环文件更改为666
- cli php可以很好地加密字符串
PHP 5.2.10 (cli) (built: Nov 13 2009 11:44:05)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
但是...
调用通过网络服务器(CentOS上的Apache)运行相同脚本的 addencryptkey 时,出现退出信号分段错误(11)".
I get "exit signal Segmentation fault (11)" when invoking addencryptkey running the same script through the webserver (Apache on CentOS).
apache错误日志
apache errorl log
[notice] child pid 30682 exit signal Segmentation fault (11)
系统日志中没有任何价值...
nothing of value in syslog...
任何指针?谢谢!
代码(没什么大不了的):
code (nothing earth shattering):
// GnuPG code
putenv("GNUPGHOME=/opt/.gnupg/");
$gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_EXCEPTION);
$gpg -> setarmor(1);
try
{
$info = $gpg -> addencryptkey("KEY");
var_dump($info);
$enc = $gpg -> encrypt($token);
var_dump($enc);
}
catch (Exception $e) {
echo 'ERROR: ' . $e->getMessage();
}
drwxr-xr-x 2 root root 4096 Jan 14 11:29 .gnupg
[root@dev-lamp01 opt]# ll .gnupg/
total 28
-rw-rw-rw- 1 root root 9224 Jan 14 10:23 gpg.conf
-rw-rw-rw- 1 root root 325 Jan 14 10:25 pubring.gpg
-rw-rw-rw- 1 root root 0 Jan 14 10:20 pubring.gpg~
-rw-rw-rw- 1 root root 600 Jan 14 11:29 random_seed
-rw-rw-rw- 1 root root 0 Jan 14 10:20 secring.gpg
-rw-rw-rw- 1 root root 1200 Jan 14 10:25 trustdb.gpg
推荐答案
哦-我的错-尽快做到
chmod -R 777
在我的GNUPGHOME上-一切正常
on my GNUPGHOME - it all worked
以为它对666很满意(而CLI对rw感到满意)
thought it was happy with 666 (and CLI was happy with just rw)
这篇关于Web服务器中的PHP GnuPG segfaults的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!