Search code examples
pythonssltcptwisted

How to know if my server is using SSL or not (with Twisted)


I've wrote a simple client and a server. They both can configured to use SSL or not. You can set it up in the client and in the server. My problem is, if I try to connect without SSL to a server setup with SSL, the connection is made but stuck. (of course... it is normal). How my client can know that he is trying to connect without SSL to a server using SSL? and vice versa?

The best solution will be that my client autodetect if server use SSL or not and do the proper connect(TCP or SSL).

Thans in advance for any answer =)


Solution

  • Use a different port number for SSL connections. This is how HTTP / HTTPS are used.

    Or

    Define a command in your protocol to transform the connection into SSL e.g. STARTTLS, based on a capability negotiation. This is one way the same thing is achieved in SMTP.