Strange behavior with TLS with self-signed certs