Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll over self-updater key for 2025 #3048

Merged
merged 7 commits into from
Feb 13, 2025

Conversation

dominikschulz
Copy link
Member

@dominikschulz dominikschulz commented Feb 8, 2025

We missed to supply a new key before the old key expired again and one of the tests started to fail once the old key was expired.

This is a more comprehensive approach to address this going forward. Not perfect, yet. But should put us (especially myself) in a better position next time this comes up.

Changes in this PR:

  • The public part of the new key that I have generated. The private part will be injected into GHA by the time this is being merged.
  • A sloppy write-up of the steps I did this time so I have less trial and error the next time we need to roll over keys.
  • A copy of the verification test that mocks the verification time 6 Months into the future. That way we should notice before the key is actually expired. This isn't perfect, because we will then have unrelated test failures 6 Months before the key expires, but at least this gives me ~1.5y to figure out a better way of giving an advance notice.

Fixes #3047

@dominikschulz dominikschulz added the release Release related label Feb 8, 2025
Signed-off-by: Dominik Schulz <[email protected]>
-----END PGP PUBLIC KEY BLOCK-----
`),
// 2023 key - 0x560D8522
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to keep the 2023 key but not the 2024 one?

Copy link
Member Author

@dominikschulz dominikschulz Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no 2024 key. When I started this feature I did settle for a 2y expiry. Happy to discuss and change that going forward.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, but my question was then:
why delete the key starting with mQGNBGAH4iEBDAC6ZXN/hzyrB8GA8KdQEasGOrri86GDsyyyRPHP1 instead of storing it like the below one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why I wasn't deleting the expired key? Good point. For a proper key rollover we can't do that, but since it already expired I can kill it.

Comment on lines 45 to 57
// Can not run parallel because we're overwriting the global timeNow variable.
timeNow = func() time.Time {
return time.Now().Add(6 * 30 * 24 * time.Hour)
}
defer func() {
timeNow = func() time.Time {
return time.Now()
}
}()

ok, err := gpgVerify(testData, testSignature)
require.NoError(t, err, "If TestGPGVerify succeeds but this test fails the self-updater key is about to expire. Please open an issue to update the key. Thank you.")
assert.True(t, ok)
Copy link
Member

@AnomalRoil AnomalRoil Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an alternative might be to just rely on:
func (sig *Signature) SigExpired(currentTime time.Time) bool
https://github.com/ProtonMail/go-crypto/blob/d703f494c90d2fa80fdbbaf33c084a7225411b55/openpgp/packet/signature.go#L760-L762
for the signature returned by PrimarySelfSignature:
https://github.com/ProtonMail/go-crypto/blob/d703f494c90d2fa80fdbbaf33c084a7225411b55/openpgp/keys.go#L887-L892

Something like:

Suggested change
// Can not run parallel because we're overwriting the global timeNow variable.
timeNow = func() time.Time {
return time.Now().Add(6 * 30 * 24 * time.Hour)
}
defer func() {
timeNow = func() time.Time {
return time.Now()
}
}()
ok, err := gpgVerify(testData, testSignature)
require.NoError(t, err, "If TestGPGVerify succeeds but this test fails the self-updater key is about to expire. Please open an issue to update the key. Thank you.")
assert.True(t, ok)
// we only check the latest pubkey
keyList, err := openpgp.ReadArmoredKeyRing(bytes.NewReader(pubkey[0]))
if err != nil || len(keyList) < 1 {
debug.Log("failed to read public key: %q", err)
return false, fmt.Errorf("failed to read public key: %w", err)
}
sig, _ := keyList[0].PrimarySelfSignature()
require.False(t, sig.SigExpired(time.Now().AddDate(0,6,0)), "If TestGPGVerify succeeds but this test fails the self-updater key is about to expire. Please open an issue to update the key. Thank you.")

So that we don't need to change gpgVerify and use a global variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion. I'll try that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That didn't seem to work. The self-sig didn't have an expriation in my case. Something else must have been expired (subkey, signature, ...).

Signed-off-by: Dominik Schulz <[email protected]>
Signed-off-by: Dominik Schulz <[email protected]>
Signed-off-by: Dominik Schulz <[email protected]>
Signed-off-by: Dominik Schulz <[email protected]>
@AnomalRoil AnomalRoil merged commit 01b6ff1 into gopasspw:master Feb 13, 2025
8 checks passed
@dominikschulz dominikschulz deleted the fix/updater-2025 branch February 13, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Release related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update release signing key
2 participants