Fix bug that forced SSL when TLS is optional

fixes #2215