Skip to content

Add TLS support for incoming mails - #435

Merged
djfarrelly merged 2 commits into
maildev:masterfrom
sharat87:feat/incoming-tls
Jul 20, 2023
Merged

djfarrelly merged 2 commits into
maildev:masterfrom
sharat87:feat/incoming-tls

Conversation

@sharat87

Copy link
Copy Markdown
Contributor

Fixes #182
Fixes #429

This PR adds support for TLS for incoming SMTP connections. We add the following three new arguments to configure support for this. Unless the --incoming-secure option is set, absolutely no change should be there from status quo.

Options Environment variable Description
--incoming-secure MAILDEV_INCOMING_SECURE Use SMTP SSL for incoming emails
--incoming-cert <path> MAILDEV_INCOMING_CERT Cert file location for incoming SSL
--incoming-key <path> MAILDEV_INCOMING_KEY Key file location for incoming SSL

The contribution guidelines speak of checking lint result, which I've just done. Let me know if you need anything else from me to make this PR more aligned.

Thank you for all the tremendous work on maildev! 🙏

@san-slysz

Copy link
Copy Markdown

@djfarrelly, @soulteary can you consider this PR 👀? If it's good stuff, than several people would be happy as it would solve the TLS support topic. If not, any feedback to @sharat87 may unlock this.

Comment thread lib/mailserver.js
logger: false,
hideSTARTTLS: true,
disabledCommands: user && password ? ['STARTTLS'] : ['AUTH']
disabledCommands: user && password ? [] : ['AUTH']

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.

It looks like a default behavior has been modified here, and there may be some compatibility issues.

Would it be better to handle a separate config configuration based on the secure status? Perhaps a simple discussion is needed here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey, thanks for checking this out. Good point. I think something like this would be more backwards compatible:

disabledCommands: user && password ? (isSecure ? [] : ['STARTTLS']) : ['AUTH']

I can push this change if it looks okay.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me - I'll just add this change and get this merged!

Suggested change
disabledCommands: user && password ? [] : ['AUTH']
disabledCommands: user && password ? (isSecure ? [] : ['STARTTLS']) : ['AUTH']

Comment thread lib/mailserver.js
Comment on lines +185 to +186
cert: certFilePath ? fs.readFileSync(certFilePath) : null,
key: keyFilePath ? fs.readFileSync(keyFilePath) : null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

isn't maildev currently using self signed certs for this? Can we keep this behavior as a fallback?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it does. From what I can tell from my understanding of the code, here's any support for SSL, self-signed or not, currently. So this shouldn't be breaking any existing configurations.

@jan--f

jan--f commented Mar 7, 2023

Copy link
Copy Markdown

Thanks, I really like this PR. This would also fix #449 and consequently superseed #450

Fixes: #449

@djfarrelly djfarrelly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great - I'll get the additional change that @soulteary and @sharat87 suggested on the main branch

Comment thread lib/mailserver.js
logger: false,
hideSTARTTLS: true,
disabledCommands: user && password ? ['STARTTLS'] : ['AUTH']
disabledCommands: user && password ? [] : ['AUTH']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me - I'll just add this change and get this merged!

Suggested change
disabledCommands: user && password ? [] : ['AUTH']
disabledCommands: user && password ? (isSecure ? [] : ['STARTTLS']) : ['AUTH']

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.

tls for incoming mails Support for TLS (via ngrok or somehow?)

5 participants