Tls patches

This is my first try for a github pull request, hope it's good :)

I'll also send some comments by email, regarding your last reply.

Thanks,
Pierre