Skip to content

fix: fix the order of arguments to merge_openpgp_certificates() call - #8847

Merged
link2xt merged 6 commits into
mainfrom
link2xt/merge_openpgp_certificates-swapped-arguments
Oct 24, 2026
Merged

link2xt merged 6 commits into
mainfrom
link2xt/merge_openpgp_certificates-swapped-arguments

Conversation

@link2xt

@link2xt link2xt commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

This fixes flaky tests/test_securejoin.py::test_qr_scan_updates_new_relay_address which hanged during the second securejoin on fast network (e.g. when testing against local container) as Bob received securejoin pubkey message from Alice but did not merge the new relay list.

@link2xt

This comment was marked as outdated.

@link2xt
link2xt force-pushed the link2xt/merge_openpgp_certificates-swapped-arguments branch from 15f5e1f to 7af89b8 Compare October 22, 2026 15:16
@link2xt
link2xt marked this pull request as ready for review October 22, 2026 15:17
@link2xt
link2xt force-pushed the link2xt/merge_openpgp_certificates-swapped-arguments branch from 7af89b8 to aaa7e3c Compare October 22, 2026 17:04
@link2xt
link2xt requested review from Hocuri and hpk42 October 22, 2026 20:08
Comment thread src/pgp/pgp_tests.rs
/// Tests that Direct Key Signature from the new certificate is preferred
/// when the timestamp is the same.
#[test]
fn test_merge_openpgp_certificates_tiebreak() -> Result<()> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this test also passes on main, so it's not about what this PR changes which is what i expected it would do. Wouldn't it be a more interesting test to import two same-second signed certs via import_public_key and see that the second one wins?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added similar test_import_public_key_tiebreak, it is failing without the fix.

Comment thread src/pgp.rs
});
let users: Vec<SignedUser> = best_user.into_iter().collect();

let public_subkeys = old_public_subkeys;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this unconditionally takes the keys form the stored cert instead of the received one, without any same-second timestamp comparison. This probably only matters with Autocrypt2 because our ac1 keys never change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Merging of subkeys is implemented #8344, but it is currently a draft and has no tests.

@hpk42 hpk42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think it's ok to merge. ac1 sub keys don't change but for ac2 we will need to revisit this merging, and probably have more refined logic for merging incoming/stored subkeys.

It is not obvious that relay list is comma-separated.
…ts()

pk_encrypt() already uses current timestamp to select the key for encryption,
no need to use a potentially different timestamp to sign the message.
This tests that the order of arguments
to merge_openpgp_certificates() is important
if signature timestamp is the same.
This fixes flaky tests/test_securejoin.py::test_qr_scan_updates_new_relay_address
which hanged during the second securejoin on fast network (e.g. when testing against local container)
as Bob received securejoin pubkey message from Alice but did not merge the new relay list.
@link2xt
link2xt force-pushed the link2xt/merge_openpgp_certificates-swapped-arguments branch from aaa7e3c to d755d69 Compare October 23, 2026 10:09
@link2xt
link2xt merged commit df19d9d into main Oct 24, 2026
29 of 30 checks passed
@link2xt
link2xt deleted the link2xt/merge_openpgp_certificates-swapped-arguments branch October 24, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants