>백엔드 개발 >PHP 튜토리얼 >Crypt_GPG 디버깅 프로세스

Crypt_GPG 디버깅 프로세스

WBOY
WBOY원래의
2016-07-29 09:15:511147검색

브라우저 측 오류 출력 정보 :

<code>( ! ) Fatal error: Uncaught <span><<span>table</span><span>style</span>=<span>"border: 1px"</span><span>cellspacing</span>=<span>"0"</span>></span><span><<span>tr</span>></span><span><<span>td</span><span>colspan</span>=<span>"3"</span><span>style</span>=<span>"background: #ff9999"</span>></span><span><<span>b</span>></span>Crypt_GPG_FileException<span></<span>b</span>></span>: The 'homedir' &quot;/Library/WebServer/.gnupg&quot; is not readable or does not exist and cannot be created. This can happen if 'homedir' is not specified in the Crypt_GPG options, Crypt_GPG is run as the web user, and the web user has no home directory. in <span><<span>b</span>></span>/usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php<span></<span>b</span>></span> on line <span><<span>b</span>></span>278<span></<span>b</span>></span><span></<span>td</span>></span><span></<span>tr</span>></span><span><<span>tr</span>></span><span><<span>td</span><span>colspan</span>=<span>"3"</span><span>style</span>=<span>"background-color: #aaaaaa; text-align: center; font-weight: bold;"</span>></span>Exception trace<span></<span>td</span>></span><span></<span>tr</span>></span><span><<span>tr</span>></span><span><<span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; width:20px; font-weight: bold;"</span>></span>#<span></<span>td</span>></span><span><<span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; font-weight: bold;"</span>></span>Function<span></<span>td</span>></span><span><<span>td</span><span>style</span>=<span>"text-align: center; background: #cccccc; font-weight: bold;"</span>></span>Location<span></<span>td</span>></span><span></<span>tr</span>></span><span><<span>tr</span>></span><span><<span>td</span><span>style</span>=<span>"text-align: center;"</span>></span>0<span></<span>td</span>></span><span><<span>td</span>></span>Crypt_GPG_Engine->__construct(Array)<span></<span>td</span>></span><span><<span>td</span>></span>/usr/local/webdata/andy/fanli/citic/Crypt/GPGAbstract.php in /usr/local/webdata/andy/fanli/citic/Crypt/GPG/Engine.php on line 541</code>

명령줄 오류 정보 출력 :

<code>PHP Fatal error:  Uncaught PEAR_Exception: gpg<span>-agent</span> binary <span>not</span> found<span>.</span><span>If</span> you are sure the gpg<span>-agent</span> is installed, please specify the location of the gpg<span>-agent</span> binary using the <span>'agent'</span> driver option<span>.</span><span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php <span>on</span> line <span>278</span><span>#0</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php(<span>278</span>): Crypt_GPG_Engine<span>-></span>__construct(<span>Array</span>)
<span>#1</span> /usr/<span>local</span>/webdata/andy/fanli/citic/gpg2<span>.</span>php(<span>9</span>): Crypt_GPGAbstract<span>-></span>__construct()
<span>#2</span> {main}
  thrown <span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPG/Engine<span>.</span>php <span>on</span> line <span>601</span>Fatal error: Uncaught PEAR_Exception: gpg<span>-agent</span> binary <span>not</span> found<span>.</span><span>If</span> you are sure the gpg<span>-agent</span> is installed, please specify the location of the gpg<span>-agent</span> binary using the <span>'agent'</span> driver option<span>.</span><span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php <span>on</span> line <span>278</span><span>#0</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPGAbstract<span>.</span>php(<span>278</span>): Crypt_GPG_Engine<span>-></span>__construct(<span>Array</span>)
<span>#1</span> /usr/<span>local</span>/webdata/andy/fanli/citic/gpg2<span>.</span>php(<span>9</span>): Crypt_GPGAbstract<span>-></span>__construct()
<span>#2</span> {main}
  thrown <span>in</span> /usr/<span>local</span>/webdata/andy/fanli/citic/Crypt/GPG/Engine<span>.</span>php <span>on</span> line <span>601</span></code>

첫 번째 브라우저에서 보고된 오류에 대한 나의 분석 권한 문제입니다. 두 번째 것이 셸에서 실행되는 것이 실제 문제입니다. 프롬프트에 따라 Brew를 사용하여 gpg-agent를 설치하세요.

이후 아래와 같이 코드를 작성했습니다.

<code><span>require_once</span><span>'./Crypt/GPG.php'</span>;

<span>$gpg</span> = <span>new</span> Crypt_GPG();
<span>$key</span> = getKey();
<span>$gpg</span>->addDecryptKey(<span>'zhangsanfeng'</span>,<span>'123456'</span>);
<span>$encrypted</span> = file_get_contents(<span>'wait_for_decrpyt.txt.gpg'</span>);
<span>$data</span> = <span>$gpg</span>->decrypt(<span>$encrypted</span>);
<span>echo</span><span>'<pre class="brush:php;toolbar:false">'</span>;var_dump(<span>$data</span>);<span>exit</span>;</code>

드디어 복호화에 성공했습니다! ! !

저작권 안내: 이 글은 해당 블로거의 원본 글이므로 블로거의 허락 없이 복제할 수 없습니다.

위에서는 관련 측면을 포함하여 Crypt_GPG를 디버깅하는 과정을 소개했습니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.