It seems to be impossible to change the expiration date of *some* keys, such as the one attached (not in use by a human and part of a test suite, safe to publish).
[luca3@moore ~]$ rm -rf .gnupg [luca3@moore ~]$ gpg --import linda.asc gpg: directory '/home/luca3/.gnupg' created gpg: keybox '/home/luca3/.gnupg/pubring.kbx' created gpg: /home/luca3/.gnupg/trustdb.gpg: trustdb created gpg: key 6A48221A903A158B: public key "Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org>" imported gpg: key 6A48221A903A158B: secret key imported gpg: Total number processed: 1 gpg: imported: 1 gpg: secret keys read: 1 gpg: secret keys imported: 1 [luca3@moore ~]$ gpg --list-keys /home/luca3/.gnupg/pubring.kbx ------------------------------ pub rsa3072 2019-05-09 [C] [expired: 2022-05-05] ABC96B3B4BAFB57DC45D81B56A48221A903A158B uid [ expired] Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org>
Everything is correct up to this point. Now let us try to unexpire the key.
[luca3@moore ~]$ gpg --edit-key 6A48221A903A158B gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C trust: unknown validity: expired ssb rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> expire Changing expiration time for the primary key. Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 0 Key does not expire at all Is this correct? (y/N) y sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C <<<<<<<<<<<<<<<< WRONG trust: unknown validity: expired ssb rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg: WARNING: Your encryption subkey expires soon. gpg: You may want to change its expiration date too. gpg> save [luca3@moore ~]$ gpg --list-keys gpg: checking the trustdb gpg: no ultimately trusted keys found /home/luca3/.gnupg/pubring.kbx ------------------------------ pub rsa3072 2019-05-09 [C] [expired: 2022-05-05] ABC96B3B4BAFB57DC45D81B56A48221A903A158B uid [ expired] Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org>
The same happens if I try to keep an actual expiration date:
[luca3@moore ~]$ gpg --edit-key 6A48221A903A158B gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C trust: unknown validity: expired ssb rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> expire Changing expiration time for the primary key. Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 2y Key expires at Wed 12 Feb 2025 11:50:25 AM CET <<<<<<<<<< CORRECT: TWO YEARS FROM NOW Is this correct? (y/N) y sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C <<<<<<<<<<<<<<<<< WRONG trust: unknown validity: expired ssb rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg: WARNING: Your encryption subkey expires soon. gpg: You may want to change its expiration date too. gpg> save [luca3@moore ~]$ gpg --list-keys gpg: checking the trustdb gpg: no ultimately trusted keys found /home/luca3/.gnupg/pubring.kbx ------------------------------ pub rsa3072 2019-05-09 [C] [expired: 2022-05-05] ABC96B3B4BAFB57DC45D81B56A48221A903A158B uid [ expired] Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> Exactly the same happens if I use --quick-set-expire: [luca3@moore ~]$ gpg --quick-set-expire ABC96B3B4BAFB57DC45D81B56A48221A903A158B 0 [luca3@moore ~]$ gpg --list-keys gpg: checking the trustdb gpg: no ultimately trusted keys found /home/luca3/.gnupg/pubring.kbx ------------------------------ pub rsa3072 2019-05-09 [C] [expired: 2022-05-05] ABC96B3B4BAFB57DC45D81B56A48221A903A158B uid [ expired] Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org>
(Here I am not using a SUBFPRS argument, in order to avoid the issue of already expired subkeys:)
'--quick-set-expire FPR EXPIRE [*|SUBFPRS]' With two arguments given, directly set the expiration time of the primary key identified by FPR to EXPIRE. To remove the expiration time '0' can be used. With three arguments and the third given as an asterisk, the expiration time of all non-revoked and not yet expired subkeys are set to EXPIRE. With more than two arguments and a list of fingerprints given for SUBFPRS, all non-revoked subkeys matching these fingerprints are set to EXPIRE.
I tried cheating with the system clock by using the faketime utility and gpg's
option --faked-system-time along with --ignore-time-conflict and
--ignore-valid-from. But even by operating on a freshly emptied .gnupg/
directory and at a time where the key is not yet expired I found no way of
changing the expiration date.
I can unexpire the two subkeys:
[luca3@moore ~]$ gpg --edit-key ABC96B3B4BAFB57DC45D81B56A48221A903A158B gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C trust: unknown validity: expired ssb rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> key -1 sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C trust: unknown validity: expired ssb* rsa3072/713A187451941578 created: 2019-05-09 expired: 2022-05-05 usage: E ssb* rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: 2022-05-05 usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> expire Are you sure you want to change the expiration time for multiple subkeys? (y/N) y Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 0 Key does not expire at all Is this correct? (y/N) y sec rsa3072/6A48221A903A158B created: 2019-05-09 expired: 2022-05-05 usage: C trust: unknown validity: expired ssb* rsa3072/713A187451941578 created: 2019-05-09 expired: never usage: E ssb* rsa3072/DCD555B6055ADE22 created: 2019-05-09 expired: never usage: S [ expired] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> save [luca3@moore ~]$
But the main key remains unusable.
This is the main version I was using while I discovered the problem:
[luca3@moore ~]$ gpg --version gpg (GnuPG) 2.2.40 libgcrypt 1.10.1 Copyright (C) 2022 g10 Code GmbH License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: /home/luca3/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2
But then I have also compiled the latest GPG release from source and tried with that, to no avail:
[luca3@moore ~]$ gpg --version gpg (GnuPG) 2.4.0 libgcrypt 1.10.1 Copyright (C) 2021 Free Software Foundation, Inc. License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: /home/luca3/.gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2
This might be more remarkable. I can reproduce the issue with gpg 1.4.23 as well:
[luca3@moore ~]$ rm -rf .gnupg/ [luca3@moore ~]$ faketime '2022-05-01' gpg1 --import linda.asc gpg: directory `/home/luca3/.gnupg' created gpg: new configuration file `/home/luca3/.gnupg/gpg.conf' created gpg: WARNING: options in `/home/luca3/.gnupg/gpg.conf' are not yet active during this run gpg: keyring `/home/luca3/.gnupg/secring.gpg' created gpg: keyring `/home/luca3/.gnupg/pubring.gpg' created gpg: key 903A158B: secret key imported gpg: /home/luca3/.gnupg/trustdb.gpg: trustdb created gpg: key 903A158B: public key "Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) gpg: secret keys read: 1 gpg: secret keys imported: 1 [luca3@moore ~]$ faketime '2022-05-01' gpg1 --list-keys /home/luca3/.gnupg/pubring.gpg ------------------------------ pub 3072R/903A158B 2019-05-09 [expires: 2022-05-05] uid Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> sub 3072R/51941578 2019-05-09 [expires: 2022-05-05] sub 3072R/055ADE22 2019-05-09 [expires: 2022-05-05] [luca3@moore ~]$ faketime '2022-05-01' gpg1 --edit-key 903A158B gpg (GnuPG) 1.4.23; Copyright (C) 2015 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Secret key is available. pub 3072R/903A158B created: 2019-05-09 expires: 2022-05-05 usage: C trust: unknown validity: unknown sub 3072R/51941578 created: 2019-05-09 expires: 2022-05-05 usage: E sub 3072R/055ADE22 created: 2019-05-09 expires: 2022-05-05 usage: S [ unknown] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg> expire Changing expiration time for the primary key. Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 0 Key does not expire at all Is this correct? (y/N) y pub 3072R/903A158B created: 2019-05-09 expires: 2022-05-05 usage: C <<<<<<<< WRONG trust: unknown validity: unknown sub 3072R/51941578 created: 2019-05-09 expires: 2022-05-05 usage: E sub 3072R/055ADE22 created: 2019-05-09 expires: 2022-05-05 usage: S [ unknown] (1). Linda Mary Patricia Deborah Barbara Susan Maria Nancy <linda@example.org> gpg: WARNING: Your encryption subkey expires soon. gpg: You may want to change its expiration date too. gpg> {F4571283}
I am running a recent GNU/Linux system on x86_64; a customised debian with nothing that should affect GPG at all. I do in fact use GPG every day for my email on this machine (Gnus, EasyPG) with no trouble.
Am I missing something obvious? Thanks in advance.