Not sure I mentioned it before, but I disagree with this approach. If the client provided credentials and expected a secure connection, we should raise an exception and not continue connecting.  If the client expected a plaintext connection and got a secure one, we should do the same (this case is a bit more obvious).  Also, if the client does not authenticate, we should also raise an exception early.