Fixed race condition occuring during the SSL handshake

SSL handshake and connection registration is now passed off to the main
thread