A Library to get Keys from a keyserver specified
Project description
hkp4py
A Library to get GPG/PGP keys from a Keyserver. This library uses the requests module to get the keys.
Tested Python Versions
Python 2.7
- 2.7.15
Python 3
- 3.7
Intstall via AUR
Install via PyPI
pip install hkp4py
pip3 install hkp4py
KeyServer
This object represents a keyserver using the hkp protocol.
Initialize
Initialize the KeyServer object.
# python2and3 compliance
from __future__ import absolute_import, unicode_literals, print_function
from hkp4py import KeyServer
server = KeyServer("hkps://pgp.ext.selfnet.de")
HKPS support via following pool.
The hkps pool is also supported.
hkps://hkps.pool.sks-keyservers.net
Add
Add keys to a keyserver.
key = "a long key"
server.add(key)
Search
Find keys with the keyserver object.
keys = server.search('@gnupg.org') # search by string
keys = server.search('0x{}'.format('6F4B4E15768C8C4E'), exact=True) #search by fingerprint
Key Object
for key in keys:
# Key Basic Information
print("Key Algorithm:\t{}".format(key.algo))
print("Key fpr:\t{}".format(key.keyid))
print("Key Length:\t{}".format(key.key_length))
print("Disabled?\t{}".format('yes' if key.disabled else 'no'))
print("Expired?\t{}".format('yes' if key.expired else 'no'))
print("Revoked?\t{}".format('yes' if key.revoked else 'no'))
print("From Host:\t{}".format(key.host))
print("From Port:\t{}".format(key.port))
print("Date Created:\t{}".format(key.creation_date))
print("Date Expired:\t{}".format(key.expiration_date))
print(key.key)
print(key.key_blob)
Identity Object
for identity in key.identities:
print("Identity:\t{}".format(identity.uid))
print("\tDisabled?\t{}".format('yes' if identity.disabled else 'no'))
print("\tExpired?\t{}".format('yes' if identity.expired else 'no'))
print("\tRevoked?\t{}".format('yes' if identity.revoked else 'no'))
print("\tDate Created:\t{}".format(identity.creation_date))
print("\tDate Expired:\t{}".format(identity.expiration_date))
More Advanced options
To set a different User-Agent and proxies for veiling purposes. The KeyServer has the following additional options for the connection.
server = KeyServer("hkps://pgp.ext.selfnet.de",
proxies={"http": "socks5h://localhost:5050", "https":
"socks5h://localhost:5050"},
headers={"User-Agent": "Testing"})
Import key with gpgme python bindings
from __future__ import absolute_import, unicode_literals
import gpg
result = gpg.Context().key_import(key.key_blob)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hkp4py-0.2.3.1.tar.gz
(6.9 kB
view details)
Built Distribution
File details
Details for the file hkp4py-0.2.3.1.tar.gz
.
File metadata
- Download URL: hkp4py-0.2.3.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9f24abc4e5eb4ee8c760474c20c79b06640951604bb16aac3f1ff3161949726 |
|
MD5 | e348119893f29dfd06a5752fd83f0907 |
|
BLAKE2b-256 | 128fcfbf0ec8946dcbacab876a8e82d2f3679527d1974f5739706cbb27a5e311 |
File details
Details for the file hkp4py-0.2.3.1-py3-none-any.whl
.
File metadata
- Download URL: hkp4py-0.2.3.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6c5c1d38755292a06bf6be745d1b160c28146ba3766ee58ae9285afa358f8e1 |
|
MD5 | 4afdfa29c5eab739448fba93da3e71f6 |
|
BLAKE2b-256 | fefddbc9ff38a36f0b9711f147de1f26a35c19c6f9de55b07222c17d3d1d0c20 |