Skip to main content

Crate imap_tls

Crate imap_tls 

Source
Expand description

TLS adapter for imap-rs.

Two entry points:

  • connect_tls — direct TLS (port 993). The connector validates the server cert against the Mozilla CA root set (webpki-roots).
  • connect_starttls — port 143 cleartext, then upgrade to TLS via the STARTTLS capability (RFC 3501 §6.2.1). Capabilities are re-fetched inside the encrypted channel — pre-TLS server-asserted capabilities are NEVER trusted.

Both entry points enforce a TCP-connect timeout and a TLS-handshake timeout to prevent slowloris-style hangs. Defaults are 30 s; override via the _with_timeouts variants.

For tests against an in-process TLS endpoint, use handshake_with_connector with a custom TlsConnector.

Constants§

DEFAULT_CONNECT_TIMEOUT
Default deadline for the TCP connect step.
DEFAULT_HANDSHAKE_TIMEOUT
Default deadline for the TLS handshake step.
DEFAULT_PRE_TLS_TIMEOUT
Default deadline for any single pre-TLS request/response (greeting, CAPABILITY, STARTTLS).

Functions§

connect_starttls
Connect to an IMAP server in cleartext (port 143), advertise STARTTLS, upgrade the same TCP stream to TLS, and only then begin trusting the server’s capabilities.
connect_starttls_with_timeouts
Like connect_starttls but with caller-chosen timeouts.
connect_tls
Connect over TCP and immediately perform a TLS handshake (port 993).
connect_tls_with_timeouts
Like connect_tls but with caller-chosen timeouts.
default_tls_connector
Build a TlsConnector using the Mozilla web PKI root certificates.
handshake_with_connector
Perform a TLS handshake on stream and wrap the resulting TLS stream in a Session. Re-fetches CAPABILITY so the returned session reflects the post-handshake server state.
starttls_with_connector
Drive the cleartext STARTTLS handshake on stream, perform the TLS handshake, then return a Session whose capabilities have been re-fetched in the encrypted channel.