28 #include <zypp-core/fs/WatchFile> 39 #undef ZYPP_BASE_LOGGER_LOGGROUP 40 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::KeyRing" 54 {
return _keyRingDefaultAccept; }
58 MIL <<
"Set new KeyRing::DefaultAccept: " << value_r << endl;
59 _keyRingDefaultAccept = value_r;
87 data.
set(
"PublicKey", key_r);
88 data.
set(
"KeyContext", keycontext_r);
92 return data.
get<
bool>(
"TrustKey");
99 data.
set(
"Keys", keys_r);
108 data.set(
"KeyDataList", keyDataList_r );
109 data.set(
"KeySigning", keySigning_r );
110 data.set(
"KeyContext", keyContext_r );
117 struct ImportKeyCBHelper
119 void operator()(
const PublicKey & key_r )
125 catch (
const Exception & excp )
127 ERR <<
"Could not import key into rpmdb: " << excp << endl;
142 MIL <<
"Current KeyRing::DefaultAccept: " << _keyRingDefaultAccept << std::endl;
145 ImportKeyCBHelper emit;
152 rpmdbEmitSignal->trustedKeyRemoved( key );
155 emitSignal->trustedKeyRemoved( key );
159 ERR <<
"Could not delete key from rpmmdb: " << excp << endl;
void importKey(const PublicKey &key, bool trusted=false)
imports a key from a file.
bool verifyFile(const Pathname &file, const Pathname &signature, const Ring ring)
PublicKey exportTrustedPublicKey(const PublicKeyData &keyData)
Export a trusted public key identified by its key data.
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
bool isKeyTrusted(const std::string &id) const
KeyRing implementation, shared between zyppng and zypp.
This basically means, we knew the key, but it was not trusted.
PublicKey exportPublicKey(const PublicKeyData &keyData)
Export a public key identified by its key data.
Class representing one GPG Public Keys data.
void reportNonImportedKeys(const std::set< Edition > &keys_r)
Notify the user about keys that were not imported from the rpm key database into zypp keyring...
void dumpPublicKey(const std::string &id, bool trusted, std::ostream &stream)
std::list< PublicKey > trustedPublicKeys()
Get a list of trusted public keys in the keyring (incl.
static constexpr const char * REPORT_AUTO_IMPORT_KEY
relates: reportAutoImportKey generic reports UserData::type
virtual bool askUserToAcceptUnsignedFile(const std::string &file, const KeyContext &keycontext=KeyContext())
KeyRing(const Pathname &baseTmpDir)
Default ctor.
KeyRing::Impl & pimpl()
Access to private functions for the KeyRingWorkflow implementations.
std::list< PublicKeyData > trustedPublicKeyData()
Get a list of trusted public key data in the keyring (key data only)
bool askUserToAcceptPackageKey(const PublicKey &key_r, const KeyContext &keycontext_r=KeyContext())
Ask user to trust and/or import the package key to trusted keyring, using ReportBase::report.
virtual bool askUserToAcceptUnknownKey(const std::string &file, const std::string &id, const KeyContext &keycontext=KeyContext())
we DONT know the key, only its id, but we have never seen it, the difference with trust key is that i...
callback::SendReport< target::rpm::KeyRingSignals > _rpmdbEmitSignal
virtual void infoVerify(const std::string &file_r, const PublicKeyData &keyData_r, const KeyContext &keycontext=KeyContext())
Informal callback showing the trusted key that will be used for verification.
std::list< PublicKey > publicKeys(const Ring ring) const
virtual void report(const UserData &userData_r=UserData())
The most generic way of sending/receiving data.
KeyTrust
User reply options for the askUserToTrustKey callback.
std::string readSignatureKeyId(const Pathname &signature)
bool trusted
Whether the key may validate data. Keys in Ring::General may if the user temp. trusted.
static void setDefaultAccept(DefaultAccept value_r)
Set the active accept bits.
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
zyppng::SignalProxy< void(const PublicKey &)> sigTrustedKeyAdded()
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
bool verifyFileSignature(const Pathname &file, const Pathname &signature) ZYPP_API
Verifies a file against a signature, with no user interaction.
IMPL_PTR_TYPE(Application)
void multiKeyImport(const Pathname &keyfile_r, const Ring ring)
Used by RpmDB to import the trusted keys.
PublicKeyData publicKeyData(const std::string &id, const Ring ring) const
bool isKeyKnown(const std::string &id)
true if the key id is knows, that means at least exist on the untrusted keyring
static constexpr const char * ACCEPT_PACKAGE_KEY_REQUEST
relates: askUserToAcceptPackageKey generic reports UserData::type
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
zyppng::SignalProxy< void(const PublicKey &)> sigTrustedKeyRemoved()
void allowPreload(bool yesno_r)
User has chosen not to trust the key.
Impl(const filesystem::Pathname &baseTmpDir)
virtual KeyTrust askUserToAcceptKey(const PublicKey &key, const KeyContext &keycontext=KeyContext())
Ask user to trust and/or import the key to trusted keyring.
static DefaultAccept defaultAccept()
Get the active accept bits.
RW_pointer< Impl > _pimpl
Pointer to implementation.
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
std::list< PublicKeyData > publicKeyData()
Get a list of public key data in the keyring (key data only)
Base class for Exception.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
void deleteKey(const std::string &id, const Ring ring)
Typesafe passing of user data via callbacks.
void deleteKey(const std::string &id, bool trusted=false)
removes a key from the keyring.
void reportAutoImportKey(const std::list< PublicKeyData > &keyDataList_r, const PublicKeyData &keySigning_r, const KeyContext &keyContext_r)
Notify that a repository auto imported new package signing keys.
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
bool isKeyTrusted(const std::string &id)
true if the key id is trusted
void allowPreload(bool yesno_r)
The general keyring may be populated with known keys stored on the system.
Easy-to use interface to the ZYPP dependency resolver.
callback::SendReport< KeyRingSignals > _emitSignal
bool isKeyKnown(const std::string &id) const
std::string readSignatureKeyId(const Pathname &signature)
reads the public key id from a signature
PublicKey exportKey(const std::string &id, const Ring ring) const
void importKey(const PublicKey &key, const Ring ring)
Import PublicKeys into a Ring.
virtual bool askUserToAcceptVerificationFailed(const std::string &file, const PublicKey &key, const KeyContext &keycontext=KeyContext())
The file filedesc is signed but the verification failed.
static constexpr const char * KEYS_NOT_IMPORTED_REPORT
relates: reportNonImportedKeys generic reports UserData::type
std::list< PublicKey > publicKeys()
Get a list of public keys in the keyring (incl.
bool verifyFileTrustedSignature(const Pathname &file, const Pathname &signature) ZYPP_API
void dumpPublicKey(const std::string &id, const Ring ring, std::ostream &stream)