Key object

The SourceKey object is the representation for signing keys used to validate software packages downloaded from repositories.

Attributes

path

SourceKey.path
A Pathlib.Path object pointing to this key’s file location on disk.

gpg

SourceKey.gpg
A gnupg.GPG object used for importing and manipulating GPG data.

data

SourceKey.data
The binary data stored in this key, used to verify package signatures.

Methods

reset_path()

SourceKey.reset_path(name:str=’’, path:str=’’, suffix:str=’archive-keyring’) -> None
(Re)sets the path object for this key to the key file specified. If a name is given, then the file is expected to be located within the system default signing key directory /etc/apt/keyrings. If a path is spefified, then it is assumed to be the full path to the keyring file on disk.

name

The name of a keyring file located within the system signing key directory, less any suffix or file extensions.

path

The absolute path to a keyring file located at any readable location on disk.

suffix

A suffix to append to the file name before the file extension. (Default: 'archive-keyring')

setup_gpg()

SourceKey.setup_gpg() -> None
Sets up the key-gpg object for this key and loads key data from disk (if present).

save_gpg()

SourceKey.save_gpg() -> None
Saves the GPG key data to disk.

delete_key()

SourceKey.delete_key() -> None
Deletes the key file from disk.

load_key_data()

SourceKey.load_key_data(raw=|ascii=|url=|fingerprint=) -> None

Fetches and loads a key from some remote source. Keys can be loaded from one of:

  • Raw internal data (bytes)
  • ASCII-armored keys (str)
  • Internet URL download (str)
  • Public GPG Keyserver Fingerprint (str)

raw=data (bytes)

Load a key from raw binary data. This is ideal when importing a key which has already been loaded from a binary data file or stream.

ascii=armor (str)

Load a key from an ASCII-Armored string.

url=url (str)

Download a key over an HTTPS connection. Note that keys should only be downloaded from secure sources.

fingerprint=fingerprint (str)

Fetch the key specified by fingerprint from a public keyserver.