Use local scope ::Context when creating keys.

The created key was searched with FindKey(), that operates on the class
scope ::Context. The latter does not use loopback pinentry. Even though,
the created key was found, the passphrase for the created key being
cached in gpg-agent.
This commit is contained in:
SET
2020-11-26 21:03:35 +01:00
parent 608ccbc1bb
commit b90ec093ad

View File

@@ -290,11 +290,11 @@ const Error GpgMEWorker::CreateKeyWithEngineDefaultAlgo(GpgME::Key& k,
KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), "default",
0, expires, k, flags);
delete ppp;
delete ctx;
if (kgr.error().code() == 0)
// Why is k not assigned the newly created key ?!
k = FindKey(kgr.fingerprint(), e, true);
k = ctx->key(kgr.fingerprint(), e, true);
delete ppp;
delete ctx;
return kgr.error();
}
@@ -318,11 +318,12 @@ const Error GpgMEWorker::CreateKey(GpgME::Key& k,
KeyGenerationResult kgr = ctx->createKeyEx(uid.c_str(), algo,
0, expires, k, flags);
delete ppp;
delete ctx;
if (kgr.error().code() == 0)
// Why is k not assigned the newly created key ?!
k = FindKey(kgr.fingerprint(), e, true);
k = ctx->key(kgr.fingerprint(), e, true);
delete ppp;
delete ctx;
return kgr.error();
}