Working TLS implementation