Support for TLS auth

Based on #226