Split out TLS stuff into a separate module