Refactor SSL/TLS debug code