tomasz buchert's page

Expired keys in Debian keyring

... or why expiration date on a GPG key is a double-edged sword

A new version of Stellarium was recently released (0.13.2), so I wanted to upload it to Debian unstable as I usually do. And so I did, but it was rejected without me even knowing, since I got no e-mail response from ftp-masters.

It turns out that my GPG key in the Debian keyring expired recently and so my upload was rightfully rejected. Not a big deal, actually, since you can easily move the expiration date (even after its expiration!). I did it already and the updated key is already propagated, but be aware that Debian keyring does not synchronize with other keyservers! To update your key in Debian (if you are a Debian Developer or Mantainer) you must send your updated keys to keyring.debian.org like that (you should replace my ID with your own):

$ gpg –keyserver keyring.debian.org –send-keys 24B17D29

Debian keyring is distributed as a standard DEB package and apparently it may take up to a month to have your updated key in Debian. It seems that I may be unable to upload packages for some time.

But the whole story made me thinking: am I the only one who forgot to update his key in Debian keyring? To verify it I wrote the following snippet (works in Python 2 and 3!) which shows keys expired in the Debian keyring (well, two of them). As a bonus, it also shows keys that have non-UTF8 characters in UIDs – see #738483 for more information.

#
# be sure to do "apt-get install python-gnupg"
#

import gnupg import datetime

def check_keys(keyring, tab = ""): gpg = gnupg.GPG(keyring = keyring) gpg.decode_errors = 'replace' # see: https://bugs.debian.org/738483 keys = gpg.list_keys() now = datetime.datetime.now() for key in keys: uids = key['uids'] uid = uids[0] if key['expires'] != '': expire = datetime.datetime.fromtimestamp(int(key['expires'])) diff = expire - now if diff.days < 0: print(u'{}EXPIRED: Key of {} expired {} days ago.'.format(tab, uid, -diff.days)) mangled_uids = [ u for u in uids if u'\ufffd' in u ] if len(mangled_uids) > 0: print(u'{}MANGLED: Key of {} has some mangled uids: {}'.format(tab, uid, mangled_uids))

keyrings = [ "/usr/share/keyrings/debian-keyring.gpg", "/usr/share/keyrings/debian-maintainers.gpg" ]

for keyring in keyrings: print(u"CHECKING {}".format(keyring)) check_keys(keyring, tab = " ")

I’m not going to show the output of this code, because it contains names and e-mail adresses which I really shouldn’t post. But you can run it yourself. You will see that there is a small group of people with expired keys (including me!). Interestingly, some keys have expired a long time ago: there is one that expired more than 7 years ago!

The outcome of the story is: yes, you should have an expiration date on your key for safety reasons, but be careful - it can surprise you at the worst moment.


inspired by classicthesis / 2021