Skip to content

Add option to force encryption#8220

Open
link2xt wants to merge 4 commits into
mainfrom
link2xt/process-unencrypted
Open

Add option to force encryption#8220
link2xt wants to merge 4 commits into
mainfrom
link2xt/process-unencrypted

Conversation

@link2xt
Copy link
Copy Markdown
Collaborator

@link2xt link2xt commented May 7, 2026

Closes #7494

There is a new force_encryption config which is enabled by default. For users with recently active unencrypted chats it is disabled in a migration. Enabling it prevents both sending and receiving unencrypted messages, so when sending to unencrypted chats we will no longer send unencrypted message to a chatmail relay for it to be rejected, but fail locally.

There are many changes to tests because we had a lot of tests using unencrypted chats, I have put them into separate commits.

The setting is not per-relay as there have been more discussion after the comments below. UIs will put the setting somewhere deeper than "Advanced" likely inside the "Relays" configuration but not in the individual relay settings.

@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 8 times, most recently from 8914248 to f1652d4 Compare May 12, 2026 12:50
@r10s

This comment was marked as outdated.

@link2xt

This comment was marked as outdated.

@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 4 times, most recently from bb4bde4 to b47d145 Compare May 13, 2026 20:48
@link2xt link2xt changed the title WIP: feat: add option to process unencrypted messages Add option to force encryption May 13, 2026
@link2xt link2xt marked this pull request as ready for review May 13, 2026 20:49
@link2xt link2xt marked this pull request as draft May 13, 2026 20:49
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch from b47d145 to c67dc51 Compare May 13, 2026 20:49
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 3 times, most recently from 15d971f to a1137cb Compare May 14, 2026 18:41
@hpk42 hpk42 added the blocker label May 14, 2026
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 3 times, most recently from a412867 to 5836a72 Compare May 14, 2026 23:41
@link2xt link2xt changed the base branch from main to link2xt/remove-timesmearing May 15, 2026 00:17
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 2 times, most recently from 098f508 to cb8ffb6 Compare May 15, 2026 01:50
@link2xt link2xt force-pushed the link2xt/remove-timesmearing branch from 2b97913 to 5e61bba Compare May 15, 2026 01:50
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch 6 times, most recently from ec863ca to ae4c3f3 Compare May 15, 2026 15:10
@link2xt link2xt marked this pull request as ready for review May 15, 2026 15:29
Comment thread src/sql/migrations.rs
Comment thread src/imap.rs Outdated
Comment thread src/e2ee.rs
Comment thread src/test_utils.rs Outdated
Comment thread src/test_utils.rs Outdated
Comment thread src/imap.rs
Comment thread src/calls/calls_tests.rs
let encrypted_message = test_utils::encrypt_raw_message(
bob,
&[alice],
b"From: bob@example.net\r\n\
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe replace "\n" with "\r\n" in encrypt_raw_message() before encryption, or do we sometimes need just "\n"?

Comment thread src/sql/migrations.rs

let now = tools::time();
let max_unencrypted_timestamp = std::cmp::max(max_unencrypted_timestamp, max_mailing_list_timestamp);
if max_unencrypted_timestamp.saturating_add(3600 * 24 * 90) > now {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete_device_after affects this if it's set to <= 5 weeks. It may even be disabled, but set right before, we can't know that. Just disabling force_encryption for existing users is probably not what we want however. Maybe it makes sense to also check if there are any messages older than 90 days at all, not sure.

Comment thread src/e2ee.rs
assert!(chat::send_msg(alice, chat.id, &mut msg).await.is_err());
assert_eq!(
msg.error().unwrap(),
"\u{26a0}\u{fe0f} Your email provider example.org requires end-to-end encryption which is not setup yet."
Copy link
Copy Markdown
Collaborator

@iequidoo iequidoo May 19, 2026

Choose a reason for hiding this comment

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

"Your server" or "Your relay" may be better these days, may be reworded in another PR

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.

This is a fallback wording, it is replaced by the UIs even for English version. Can be tweaked, but the user never sees this.

@link2xt link2xt changed the base branch from link2xt/remove-timesmearing to main May 19, 2026 16:35
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch from 4747fa7 to 65ed62a Compare May 19, 2026 16:37
link2xt added 2 commits May 19, 2026 19:22
This change is a preparation for ignoring
unencrypted messages by default.

New test_utils::encrypt_raw_message and
test_utils::receive_encrypted_imf are
used to encrypt the messages before
"receiving" them with receive_imf.
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch from 65ed62a to 4046ca5 Compare May 19, 2026 17:22
@link2xt link2xt force-pushed the link2xt/process-unencrypted branch from 4046ca5 to a9aa493 Compare May 19, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to process unencrypted messages

5 participants