Fix crash due to SSL connection problem

Handle IO exception so that we can reconnect (and we don't crash) due to
problems during ssl authentication.
This fixes the case where server closes connection during SSL
authentication