gpg: sign-key can't find self-signature

I am trying to sign another key with my key and gpg is complaining that the it’s not self-signed, but when I do --list-sigs the self signatures show up. What’s going on?

$ gpg --sign-key PUBLIC_KEY_HEX_2

sec  ed25519/SHORT_PUBLIC_KEY_HEX_2
     created: 1970-01-01  expires: never       usage: SC  
     trust: unknown       validity: unknown
ssb  cv25519/DONT_KNOW_HEX_2
     created: 1970-01-01  expires: never       usage: E   
[ unknown] (1). Me (key2) <me@example.com>

gpg: using "Me (key1) <me@example.com>" as default secret key for signing
User ID "Me (key2) <me@example.com>" is not self-signed.  Unable to sign.
Nothing to sign with key SHORT_PUBLIC_KEY_HEX_1

Key not changed so no update needed.
$ gpg --list-sigs PUBLIC_KEY_HEX_2
pub   ed25519 1970-01-01 [SC]
      PUBLIC_KEY_HEX_2
uid           [ unknown] Me (key2) <me@example.com>
sig 3        SHORT_PUBLIC_KEY_HEX_2 1970-01-01  [self-signature]
sub   cv25519 1970-01-01 [E]
sig          SHORT_PUBLIC_KEY_HEX_2 1970-01-01  [self-signature]

As far as I can tell this is telling me that a key that clearly is self-signed isn’t self-signed. I’ve tried googling a bit and everything talks about how to self-sign or similar, but I don’t see anything where --list-sigs and says it’s self signed and some other component says it isn’t.

Possibly relevant details:

  • key1 is a key that was created in this environment
  • key2 is a key that was created in a different GNUPGHOME directory, exported from there and is getting imported here
  • I’m using GNUPGHOME=~/.gnupg/onlykey/
  • I’m using a hardware encryption device (onlykey), I don’t actually have the secret key, just the public key (never had trouble with this before, but just thought I’d mention it)

P.S. The reason I’m trying to do this is because I have one off-line key and two hardware keys. I want to have all the keys signed by each other so that as I import them they’ll just be automatically trusted on any computer I’m pulling them into that already has one of the keys trusted.

Hi CrazyCasta!

Which gpg version are you using?

To get more information on the signatures, if it is from the 2.4 branch, please enter:
gpg --full-timestrings --check-sigs PUBLIC_KEY_HEX_2

For a 2.2 version you have to use:
gpg --with-colons --check-sigs PUBLIC_KEY_HEX_2
This also contains the timestring, but as unix time.

It is suspicious that the time of the selfsignatures is the epoch.

I’m on 2.4.5

$ gpg --version
gpg (GnuPG) 2.4.5
libgcrypt 1.10.3-unknown
Copyright (C) 2024 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/user/.gnupg/onlykey
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

Here’s the output of the check-key bit:

$ gpg --full-timestrings --check-sigs PUBLIC_KEY_HEX_2
pub   ed25519 1970-01-01 00:00:00 [SC]
      PUBLIC_KEY_HEX_2
uid           [ unknown] Me (key2) <me@example.com>
sig!3        SHORT_PUBLIC_KEY_HEX_2 1970-01-01 00:00:00  [self-signature]
sub   cv25519 1970-01-01 00:00:00 [E]
sig!         SHORT_PUBLIC_KEY_HEX_2 1970-01-01 00:00:00  [self-signature]

gpg: 2 good signatures

I tried my other key, which is just a standard file based gpg key and it worked. I’m starting to think you’re right that’s it’s related to the time number being 0. Is this not a bug in gpg (not handling epoch properly)? I’ll also check to see if there’s any way to get a proper date from onlykey-gpg, but I’m guessing there might not be.

Ok, seems that it’s a feature to make it possible to recreate the gpg identity without having to remember anything and just needing the key: OnlyKey SSH/GPG agent | Docs

Would be nice to use that feature if I could and still sign keys.

Is this not a bug in gpg (not handling epoch properly)?

No, this is not a bug but a side effect of using unix time. By convention 0 (which is displayed in unix time context as 1970-01-01 00:00:00) is used for “no date”. So the selfsignature has no date and as a signature has to have a date it does not exist from gpgs point of view.

So you should use the -t option of onlykey-gpg (as described in the link you gave) if you want to sign that key with gpg.

Though it might be that adding --expert to your gpg --sign-key command would make it work despite the “missing” date of the selfsignature. Try it out.

Did you intentionally set the creation date of your OpenPGP key to the epoch?