unpythonicguy
unpythonicguy

Reputation: 141

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 =)

Upvotes: 1

Views: 635

Answers (2)

user207421
user207421

Reputation: 310978

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

Not possible. The first event in an SSL connection is a message from the client, not from the server.

Upvotes: 0

MattH
MattH

Reputation: 38245

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.

Upvotes: 5

Related Questions