当我运行它时,输出有点可疑:
# add-apt-repository -y ppa:ansible/ansible
gpg: keyring `/tmp/tmp85zwje4_/secring.gpg' created
gpg: keyring `/tmp/tmp85zwje4_/pubring.gpg' created
gpg: requesting key 7BB9C367 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp85zwje4_/trustdb.gpg: trustdb created
gpg: key 7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
我们不应该通过如此短的字符串来识别键,因为冲突的 keyid 可以在5秒以内。
答案1
不用担心这个输出。
尽管 GPG 会打印过时的 keyid,但 apt-add-repository 实际上是使用其 160 位指纹来获取密钥。 (指纹似乎是通过 HTTPS 获取的)。
def verify_keyid_is_v4(signing_key_fingerprint):
"""Verify that the keyid is a v4 fingerprint with at least 160bit"""
return len(signing_key_fingerprint) >= 160/8
class AddPPASigningKey(object):
" thread class for adding the signing key in the background "
GPG_DEFAULT_OPTIONS = ["gpg", "--no-default-keyring", "--no-options"]
def __init__(self, ppa_path, keyserver=None):
self.ppa_path = ppa_path
self.keyserver = (keyserver if keyserver is not None
else DEFAULT_KEYSERVER)
def _recv_key(self, keyring, secret_keyring, signing_key_fingerprint, keyring_dir):
try:
# double check that the signing key is a v4 fingerprint (160bit)
if not verify_keyid_is_v4(signing_key_fingerprint):
print("Error: signing key fingerprint '%s' too short" %
signing_key_fingerprint)
return False