Skip to content

Multiplex HTTPS, IMAP and SMTP on port 443#357

Merged
link2xt merged 1 commit intomainfrom
link2xt/stream-alpn-proxy
Jul 11, 2024
Merged

Multiplex HTTPS, IMAP and SMTP on port 443#357
link2xt merged 1 commit intomainfrom
link2xt/stream-alpn-proxy

Conversation

@link2xt
Copy link
Copy Markdown
Contributor

@link2xt link2xt commented Jul 11, 2024

Services are distinguished based on ALPN.
For example,
openssl s_client -connect example.org:443 -alpn smtp
gives SMTP connection and
openssl s_client -connect example.org:443 -alpn imap
gives IMAP connection.

@link2xt
Copy link
Copy Markdown
Contributor Author

link2xt commented Jul 11, 2024

Related Delta Chat core PR making it request imap APLN: chatmail/core#5767
Need to make Delta Chat use smtp ALPN too (edit: chatmail/core#5769), then we can add port 443 with implicit TLS as a fallback third option into autoconfig.

@link2xt link2xt force-pushed the link2xt/stream-alpn-proxy branch from 5abb52f to a57619d Compare July 11, 2024 05:33
@link2xt link2xt force-pushed the link2xt/stream-alpn-proxy branch 3 times, most recently from 13fec29 to b5cd2ac Compare July 11, 2024 05:59
@link2xt link2xt marked this pull request as ready for review July 11, 2024 07:10
map $ssl_preread_alpn_protocols $proxy {
default 127.0.0.1:8443;
~\bsmtp\b 127.0.0.1:465;
~\bimap\b 127.0.0.1:993;
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.

does this mean that establishing SSL is done by imap/postfix still?

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.

Yes, it is controlled by proxy_ssl which is off by default. Passing to plaintext port would not work, I think postfix and dovecot would not be happy about authentication before STARTTLS.

Comment on lines +16 to +17
~\bsmtp\b 127.0.0.1:465;
~\bimap\b 127.0.0.1:993;
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.

can we use the /etc/service names of "imaps" and "smtps" here? i'd prefer that.

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.

Seems to work

Copy link
Copy Markdown
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

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

very nice!

@link2xt link2xt force-pushed the link2xt/stream-alpn-proxy branch from b5cd2ac to 10bf9d5 Compare July 11, 2024 10:21
Services are distinguished based on ALPN.
For example,
    openssl s_client -connect example.org:443 -alpn smtp
gives SMTP connection and
    openssl s_client -connect example.org:443 -alpn imap
gives IMAP connection.
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