I haven't tried it myself, but it looks like the secure
method in the SecureSocket documentation is exactly what you're looking for (assuming you want to use a client-side handshake, otherwise see secureServer
):
Future<SecureSocket> secure(Socket socket, {host, bool sendClientCertificate: false, String certificateName, bool onBadCertificate(X509Certificate certificate)})
Takes an already connected socket and starts client side TLS handshake to make the communication secure.