I was doing some work, when suddenly my git failed to commit changed.
error: gpg failed to sign the data
fatal: failed to write commit object
I dig a little around, asked StackOverflow but it didn’t help. Finally when running the commit manually and not through PHPStorm I got a proper error:
-> % git -c core.quotepath=false -c log.showSignature=false commit -m"Remove unused label config"
error: gpg failed to sign the data:
[GNUPG:] KEYEXPIRED 1740054190
[GNUPG:] KEY_CONSIDERED 284B8D92EFA372D24E87504F9642FF72DD74A248 3
gpg: skipped "0x9642FF72DD74A248": Unusable secret key
[GNUPG:] INV_SGNR 9 0x9642FF72DD74A248
[GNUPG:] FAILURE sign 54
gpg: signing failed: Unusable secret key
fatal: failed to write commit object
Ah! The key is expired! Got it.
Did you know you can extend a GPG key? I did 😀
I quote the answer here, thanks Sauce McBoss!
Yes, you can renew it at any time. Here’s how to do it:
gpg --list-keys gpg --edit-key (key id)
Now you’re in the gpg console. (By default, you’re working on the primary key.) If you need to update a sub-key:
gpg> key 1
Now you can set the expiration for the selected key:
gpg> expire (follow prompts) gpg> save
Now that you’ve updated your key, you can send it out:
gpg --keyserver pgp.mit.edu --send-keys (key id)
And, yes, having an expiration date for your keys is a very good idea. You should never really have a key with no expiration date. If it’s compromised, it could be used forever.
One thought on “gpg failed to sign the data”