feat(tls): add STARTTLS for FTPS, SMTP, IMAP, and POP3#2
Merged
Conversation
Implement STARTTLS — upgrading a plain TCP connection to TLS mid-stream after initial protocol negotiation. This passes 15 of 16 curl tests (400-409, 980-986, 1112); the sole remaining failure (407) is a pre-existing FTP connection reuse bug. Changes: - Add `UseSsl` enum (None/Try/All) for controlling STARTTLS behavior - Add `--ssl` → UseSsl::Try, `--ssl-reqd` → UseSsl::All CLI mapping - Add `--ftp-ssl-control` flag for PROT C (clear data channel) - Add `--ftp-ssl-ccc` flag for CCC (clear command channel) FTP/FTPS: - Try AUTH SSL before AUTH TLS (matching curl's auth order) - Return error 64 when --ssl-reqd and both AUTH commands fail - Detect pipelined server responses and return error 8 in Try mode - Send PROT C instead of PROT P when --ftp-ssl-control is set - Ignore PBSZ/PROT failures for stunnel-wrapped FTPS servers - Fix login/PBSZ ordering: implicit FTPS does USER/PASS then PBSZ/PROT SMTP: - Parse STARTTLS from EHLO capabilities - Send STARTTLS command when --ssl is used with smtp:// - Return error 8 on STARTTLS failure, error 64 when required but missing IMAP: - Parse STARTTLS from CAPABILITY response - Send STARTTLS command when --ssl is used with imap:// - Return error 64 when --ssl-reqd and CAPABILITY fails or lacks STARTTLS POP3: - Parse STLS from CAPA response - Send STLS command when --ssl is used with pop3:// - Return error 64 when --ssl-reqd and CAPA fails or lacks STLS Tests passing: 400, 401, 402, 403, 406, 408, 409, 980, 981, 982, 983, 984, 985, 986, 1112
5d0dff1 to
77c5b15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UseSslenum (None/Try/All) to control STARTTLS behavior across protocols--ssl,--ssl-reqd,--ftp-ssl-control,--ftp-ssl-cccCLI flags through Easy to protocol handlersTest plan
cargo fmt,cargo clippy,cargo test,cargo docall pass