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

feat: support s/mime encryption #1946

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

schwigri
Copy link

Hi, I use S/MIME to enable reading encrypted email using iOS and macOS Mail apps :) I've made this change and had it deployed on my own self-hosted instance, but thought I would share here. I've read through the contributing guide, but this is my first real PR so please let me know if there is anything I missed.

Also not sure if there should be other features considered (e.g. disable S/MIME for specific aliases like PGP, or some kind of fallback for S/MIME fails but fallback to PGP, etc.), so I don't really expect this will be merged immediately but thought it may be useful for others who may be interested in this feature. It could also be expanded to include signing, but for now it didn't seem necessary given the dynamic nature of the sending address.

Related to issue #527 and discussion #535!

Comment on lines +934 to +942
except Exception as exceptasdf:
LOG.w(
"Cannot S/MIME encrypt message %s -> %s. %s %s",
contact,
alias,
mailbox,
user,
)
LOG.w(exceptasdf)
Copy link
Author

Choose a reason for hiding this comment

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

Oops, sorry; I can clean up this variable name and logging

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@nguyenkims
Copy link
Contributor

Hi thanks a lot for making this PR and sorry for the late response! I'll ask our team to review the PR and come back to you at the beginning of 2024 (as most of the team is on holiday during Christmas :) )

@acasajus
Copy link
Collaborator

acasajus commented Mar 7, 2024

Hey, thanks for the contribution. As a general rule we'd like to have tests for new code that's merged into the repo to make sure that:

  • the feature works as expected
  • future changes don't break it.

Would you mind adding tests to it?

@@ -2566,6 +2566,12 @@ class Mailbox(Base, ModelMixin):
sa.Boolean, default=False, nullable=False, server_default="0"
)

# smime
smime_public_key = sa.Column(sa.Text, nullable=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you move this into a different model like MailboxSMimeKey ? We load mailboxes all the time from the db and the lighter they are, the better. We only need to load the key when we're about to use it.

url_for("dashboard.mailbox_detail_route", mailbox_id=mailbox_id)
)

mailbox.smime_public_key = request.form.get("smime")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you:

  • Verify that this is a valid PEM file.
  • Add a check that the key is not bigger than 15KiB? A PEM chain with several certs shouldn't be bigger than that.

@schwigri
Copy link
Author

Thanks for reviewing and commenting. I’ll take some time to address them due to limited bandwidth. Appreciate it!

@Teko012
Copy link

Teko012 commented May 26, 2024

@schwigri Any updates on this? :)

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.

None yet

5 participants