Do the SSL_write() in a helper function.

We will reuse that code later.

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