adjusting handling of TLS connection to work with C2SServer