When a key is expired, the command to sign a message generate a error message saying the secret key is not found, instead of public key expired.
# gpg --list-secret-keys 0x51F72B6A45D40BBE sec# rsa4096 2017-09-27 [SC] [expired: 2019-01-01] B44072EBDE14FC828F69F20651F72B6A45D40BBE uid [ expired] Cozy Debian signing key # echo test | gpg --no-autostart --clearsign --default-key 0x51F72B6A45D40BBE gpg: Warning: not using '0x51F72B6A45D40BBE' as default key: No secret key gpg: all values passed to '--default-key' ignored gpg: no default secret key: No secret key gpg: [stdin]: clear-sign failed: No secret key
Using an exported GPG agent (/run/user/1000/gnupg/S.gpg-agent.extra mount to /run/user/0/gnupg/S.gpg-agent)
Host side :
gpg --version gpg (GnuPG) 2.2.17 libgcrypt 1.8.5
Guest side :
# gpg --version gpg (GnuPG) 2.2.12 libgcrypt 1.8.4