I have a simple SMTP client, to which I am attempting to add TLS support. I am unsure as to what occurs after the client issues the 'STARTTLS' command. Most sources (including the RFC itself) describe it as the negotiation of a TLS session, but this is not particularly clear.
How does one go about doing this? My client is written in Objective C and uses Cocoa's stream objects (a wrapper for sockets). Cocoa streams have the ability to designate TLS as the the socket security level system with NSStream's setProperty function.
It seems, however, that this must be done before the connection is opened. If this is the case, then is the client expected to disconnect after receiving code 220 from the server (in response to STARTTLS) and then reconnect while specifying TLS?
Or rather, is this just a limitation of NSStream? Do plain sockets re-negotiate TLS or SSL without being closed?
Furthermore, once STARTTLS has been issued and the subsequent negotiating completed, is any other encoding/decoding expected on the part of the client?
Apologies if these are simple questions. I've had difficulty finding proper examples.
Cheers!