aboutsummaryrefslogtreecommitdiffstats
path: root/lang/cpp/src/verificationresult.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/cpp/src/verificationresult.cpp')
-rw-r--r--lang/cpp/src/verificationresult.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/lang/cpp/src/verificationresult.cpp b/lang/cpp/src/verificationresult.cpp
index a7b073e6..23c458e1 100644
--- a/lang/cpp/src/verificationresult.cpp
+++ b/lang/cpp/src/verificationresult.cpp
@@ -29,6 +29,7 @@
#include "result_p.h"
#include "util.h"
#include "key.h"
+#include "context.h"
#include <gpgme.h>
@@ -121,6 +122,7 @@ public:
std::vector<GpgME::Key> keys;
std::vector<char *> purls;
std::string file_name;
+ Protocol proto;
};
GpgME::VerificationResult::VerificationResult(gpgme_ctx_t ctx, int error)
@@ -145,6 +147,10 @@ void GpgME::VerificationResult::init(gpgme_ctx_t ctx)
return;
}
d.reset(new Private(res));
+ gpgme_protocol_t proto = gpgme_get_protocol(ctx);
+ d->proto = proto == GPGME_PROTOCOL_OpenPGP ? OpenPGP :
+ proto == GPGME_PROTOCOL_CMS ? CMS :
+ UnknownProtocol;
}
make_standard_stuff(VerificationResult)
@@ -386,6 +392,32 @@ GpgME::Key GpgME::Signature::key() const
return d->keys[idx];
}
+GpgME::Key GpgME::Signature::key(bool search, bool update) const
+{
+ if (isNull()) {
+ return Key();
+ }
+
+ GpgME::Key ret = key();
+ if (ret.isNull() && search) {
+ auto ctx = Context::createForProtocol (d->proto);
+ if (ctx) {
+ ctx->setKeyListMode(KeyListMode::Local |
+ KeyListMode::Signatures |
+ KeyListMode::SignatureNotations |
+ KeyListMode::Validate |
+ KeyListMode::WithTofu);
+ Error e;
+ ret = d->keys[idx] = ctx->key(fingerprint(), e, false);
+ delete ctx;
+ }
+ }
+ if (update) {
+ ret.update();
+ }
+ return ret;
+}
+
class GpgME::Notation::Private
{
public: