Use new Context::setExpire to set expiration dates.
If no subkey is found (wrong fpr) or not provided, the expiry time of the key is set instead. setExpire() allows to expire all subkeys at once. Not implemented here. Requires GPGME >= 1.15.0.
This commit is contained in:
@@ -173,7 +173,7 @@ const Error GpgMEWorker::RevokeKeyCertifications(const char* fprSigningKey,
|
||||
return e;
|
||||
}
|
||||
|
||||
const Error GpgMEWorker::SetSubkeyExpiryTime(const char* keyFpr,
|
||||
const Error GpgMEWorker::SetKeyExpiryTime(const char* keyFpr,
|
||||
const char* subkeyFpr,
|
||||
const string& passphrase,
|
||||
ulong expires)
|
||||
@@ -204,38 +204,12 @@ const Error GpgMEWorker::SetSubkeyExpiryTime(const char* keyFpr,
|
||||
m_ppp->SetPassphrase(passphrase);
|
||||
m_ctx->setPassphraseProvider(m_ppp);
|
||||
|
||||
// setExpire() allows to expire all subkeys at once. Not implemented here.
|
||||
e = m_ctx->setExpire(k, expires, subkey);
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
const Error GpgMEWorker::SetExpiryTime(const char * keyFpr,
|
||||
const string& passphrase,
|
||||
const string& timeString)
|
||||
{
|
||||
Error e;
|
||||
Key k = FindKey(keyFpr, e, true);
|
||||
if (e.code() != 0)
|
||||
return e;
|
||||
e = m_ctx->addSigningKey(k); // +++
|
||||
if (e.code() != 0)
|
||||
return e;
|
||||
|
||||
m_ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
|
||||
if (m_ppp == NULL)
|
||||
m_ppp = new LoopbackPassphraseProvider();
|
||||
m_ppp->SetPassphrase(passphrase);
|
||||
m_ctx->setPassphraseProvider(m_ppp);
|
||||
|
||||
SetExpiryTimeEditInteractor * interactor
|
||||
= new SetExpiryTimeEditInteractor(timeString);
|
||||
GpgME::Data d;
|
||||
e = m_ctx->edit(k, std::unique_ptr<SetExpiryTimeEditInteractor> (interactor), d);
|
||||
m_ctx->clearSigningKeys();
|
||||
// NB : with a wrong passphrase, e.code() is 0 !
|
||||
return e;
|
||||
}
|
||||
|
||||
const Error GpgMEWorker::AddUserID(const char* keyFpr, const string& passphrase,
|
||||
const string& name, const string& email,
|
||||
const string& comment)
|
||||
|
||||
Reference in New Issue
Block a user