我正在尝试检查C++项目上是否使用gpgme,但是当我尝试访问OpenPGP引擎时
我已经在计算机上安装了GnuPG,并且正在Windows下运行。
命令gpgconf
和gpg2
的工作原理还不错,因此GnuGP安装良好
我将gpgme的调试级别设置为9,但出现错误,这里是日志:
GPGME 2015-12-28 19:05:21 <0x2b18> gpgme_debug: level=9
GPGME 2015-12-28 19:05:21 <0x2b18> gpgme_debug: gpgme='D:\CODING\C++\bin\Debug'
GPGME 2015-12-28 19:05:21 <0x2b18> gpgme_check_version: call: 0=00000000, req_version=(null), VERSION=1.6.0
GPGME 2015-12-28 19:05:21 <0x2b18> gpgme_check_version_internal: call: 0=00000000, req_version=(null), offset_sig_validity=32
GPGME 2015-12-28 19:05:21 <0x2b18> gpgme-dinfo: gpgconf='C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe'
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: enter: filedes=0028F680, inherit_idx=1 (GPGME uses it for reading)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: leave: read=0x0 (00000150/0x0), write=0x1 (00000164/0x0)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: enter: path=0AF93FD0, path=C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 0] = C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 1] = --list-dirs
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, tmp_name = C:\Users\User\AppData\Local\Temp\gpgme-HBCBJ6
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, CreateProcess failed: ec=87
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: error: Input/output error
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000000
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000000, fd=0 -> handle=00000150 socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000001
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000001, fd=1 -> handle=00000164 socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: enter: filedes=0028F680, inherit_idx=1 (GPGME uses it for reading)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: leave: read=0x0 (00000168/0x0), write=0x1 (00000174/0x0)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: enter: path=0AF93FD0, path=C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 0] = C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 1] = --list-components
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, tmp_name = C:\Users\User\AppData\Local\Temp\gpgme-4Cb3i3
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, CreateProcess failed: ec=87
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: error: Input/output error
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000000
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000000, fd=0 -> handle=00000168 socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000001
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000001, fd=1 -> handle=00000174 socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: enter: filedes=0028FA5C, inherit_idx=1 (GPGME uses it for reading)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_pipe: leave: read=0x0 (0000017C/0x0), write=0x1 (00000190/0x0)
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: enter: path=0AF93FD0, path=C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 0] = C:\Program Files (x86)\GNU\GnuPG\gpgconf.exe
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, argv[ 1] = --version
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, tmp_name = C:\Users\User\AppData\Local\Temp\gpgme-DrOuSZ
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: check: path=0AF93FD0, CreateProcess failed: ec=87
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_spawn: error: Input/output error
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000000
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000000, fd=0 -> handle=0000017C socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: enter: fd=00000001
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: check: fd=00000001, fd=1 -> handle=00000190 socket=-1 dupfrom=-1
GPGME 2015-12-28 19:05:21 <0x2b18> _gpgme_io_close: leave: result=0
GPGME 2015-12-28 19:05:21 <0x2b18> engine.c:365: returning error: Invalid crypto engine
GPGME 2015-12-28 19:05:21 <0x2b18> engine.c:155: returning error: Invalid crypto engine
Invalid crypto engine
编辑:
这是我运行的代码:
#include "gpgme.h"
#include <iostream>
using namespace std;
void genKey()
{
gpgme_set_global_flag("debug","9");
gpgme_check_version(NULL);
gpg_error_t test = gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP);
cout << gpgme_strerror(test) << endl;
cout << "Engine : " << gpgme_get_dirinfo("gpg-name") << endl;
}
最佳答案
解决了 :
我将gpg4win安装在虚拟目录中,并将整个目录复制到bin中。然后在 gpgme_set_global_flag("disable-gpgconf","1")
之前添加gpgme_set_global_flag("gpg-name","gpgconf")
和gpgme_check_version(NULL)
。现在正在工作,谢谢。