1

For specifying the preferenced order of encryption algorithms in GPG I use

gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, NULL, CONFIG_DIR);

to set a custom config file. However how can I check if this operation was successful? home_dir is set to the given value, but this also happens if I pass a directory without a config file. I can't see any function or call in the documentation to evaluate if the config file was loaded OR what the current preference order is.

4

1 回答 1

1

如果发生问题,该函数将返回错误值。从文档中:

如果成功,此函数返回错误代码GPG_ERR_NO_ERROR,如果失败则返回错误代码。

您在没有配置文件的情况下设置主目录时观察到了意外行为:

home_dir设置为给定值,但是如果我传递一个没有配置文件的目录,也会发生这种情况。

这是 GnuPG 中的预期行为。空配置文件不是错误,只是意味着没有其他配置,但默认值已到位。如果你将空文件夹的引用传递给 GnuPG,也会发生类似的事情--homedir:GnuPG 将尝试将此文件夹初始化为主目录,但会打印一条信息消息:

$ LANG=C gpg --homedir /tmp
gpg: keyring `/tmp/secring.gpg' created
gpg: keyring `/tmp/pubring.gpg' created
gpg: Go ahead and type your message ...

如果您想验证文件夹是否已设置,我建议您验证一些您期望的选项,或自行测试配置文件(或您期望可用的任何内容)。

于 2016-01-21T14:09:31.393 回答