Extract ssl connection into its own helper function.

This is better to isolate SSL initialization and connection from imap
specific function.

Signed-off-by: Thiago Farina <tfarina@chromium.org>