Forum Discussion
Eino_Tuominen_2
Nimbostratus
Oct 28, 2009Offloading Imap STARTTLS
Hello everybody,
The irule:
when CLIENT_ACCEPTED {
SSL::disable
}
when SERVER_CONNECTED {
log local0.info "New connection"
TCP::collect
}
when CLIENT...
Daniel_56161
Nimbostratus
Mar 03, 2016Hello. Bellow you can find a working code for imap starttls. It can force the clients to use only TLS connection(require_starttls = 1) or it can allow unencrypted communication. The irule was tested with Thunderbird, Outlook and also openssl s_client and the backend for this irule was Dovecot.
Code
when CLIENT_ACCEPTED {
set require_starttls 0
SSL::disable
}
when SERVER_CONNECTED {
TCP::collect
}
when CLIENT_DATA {
set lcpayload [string tolower [TCP::payload]]
if { $lcpayload contains "starttls" } {
set tag [getfield [TCP::payload] " " 1]
TCP::respond "$tag OK Begin TLS negotiation now\r\n"
TCP::payload replace 0 [TCP::payload length] ""
TCP::release
SSL::enable
}
elseif { $lcpayload contains "capability" } {
serverside { TCP::collect }
TCP::release
TCP::collect
}
else {
if { $require_starttls } {
set id [getfield [TCP::payload] " " 1]
TCP::respond "BAD \"Must issue a STARTTLS command first\"\r\n"
TCP::payload replace 0 [TCP::payload length] ""
TCP::release
TCP::collect
} else {
TCP::release
}
}
}
when SERVER_DATA {
if { [TCP::payload] contains "* OK \[CAPABILITY" } {
TCP::payload replace 16 0 " STARTTLS"
TCP::release
clientside { TCP::collect }
} elseif { [TCP::payload] contains "* CAPABILITY" } {
TCP::payload replace 12 0 " STARTTLS"
TCP::release
clientside { TCP::collect }
} else {
TCP::release
TCP::collect
}
}Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects