Skip to content

Commit

Permalink
Add blocksat pubkey statically as package data
Browse files Browse the repository at this point in the history
The importing using recv_keys from a key server does not work with all gpg
versions. It was failing, e.g., on gpg 1.4.21. To overcome the problem, add the
pubkey statically as package data and import directly from there.
  • Loading branch information
blockstreamsatellite committed Dec 4, 2020
1 parent 2b58764 commit bce1333
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
20 changes: 13 additions & 7 deletions blocksatcli/api/api.py
Expand Up @@ -55,18 +55,24 @@ def config(args):
gpg.create_keys(name, email, comment)

# Import Blockstream's public key
key_server = 'keys.openpgp.org'
import_result = gpg.gpg.recv_keys(key_server, blocksat_pubkey)
#
# NOTE: the order is important here. Add Blockstream's public key only after
# adding the user key. With that, the user key becomes the first key on the
# keyring, which is used by default.
pkg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
key_path = os.path.join(pkg_dir, 'gpg', blocksat_pubkey + ".gpg")

with open(key_path) as fd:
key_data = fd.read()

import_result = gpg.gpg.import_keys(key_data)

if (len(import_result.fingerprints) == 0):
logger.warning("Failed to import key {}".format(blocksat_pubkey))
return

# Note: the order is important here. Add Blockstream's public key only after
# adding the user's key. With that, the user's key becomes the first key,
# which is used by default.
logger.info("Imported key {} from {}".format(
import_result.fingerprints[0], key_server
logger.info("Imported key {}".format(
import_result.fingerprints[0]
))

gpg.gpg.trust_keys(blocksat_pubkey, 'TRUST_ULTIMATE')
Expand Down
29 changes: 29 additions & 0 deletions blocksatcli/gpg/87D07253F69E4CD8629B0A21A94A007EC9D4458C.gpg
@@ -0,0 +1,29 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFwQEqcBCADEM4ieCV98IqiUNpJfhtZC3vGJrhIEjTpYVn6S+efMdodclkvb
QSB3hFr2pkcIBSaa+2ply/OAI1vnG5VFRW76ze+i/qnSRsHUXMPh2diCNQ4otyVq
H2hZbEw4ngjW1imh7HuQmgFzvwnIsUXDGk5/NY2moSwVHKNOAGK2taInXLWEjLSb
6qq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oJEKlKAH7J1EWM1WAH/iH8/4L2cQHo/z4W98ot/u3b
hVpmzPJtC/njHYjrhAYautppMvDmHye249XMnrGP5urS1E2CaP7L30fkRoFkDp+e
tUjoBrrgJyNIo88NMZ4e4m0ZJb78DORm3jBUX+kuofONgu0j/qAc06KEQLdegUi3
USuYjcrZJs2nZNnblsjHtrQYOeP8ZXaswL4m5aKcTOn+C2wpA36k1XQ/K8NqZ7/5
wt3xjIVthfqpqW70HdYMbdldVQ2FfB7dOxSQf1DkKKiz6YAZ1qhOAgrI+rG9Fa4f
My3QNtKgAVMo+b6+T2cVNq3sd5r4WPzJzzCOMm/HSDqTxusJi0iTSGoz9rPRhgg=
=ZlPl
-----END PGP PUBLIC KEY BLOCK-----
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -42,7 +42,7 @@
'pysnmp'
],
package_data={
'blocksatcli' : ['mib/*.mib', 'mib/*.txt']
'blocksatcli' : ['mib/*.mib', 'mib/*.txt', 'gpg/*.gpg']
},
classifiers=[
'Programming Language :: Python :: 3',
Expand Down

0 comments on commit bce1333

Please sign in to comment.