[Twisted-Python] Could I serve normal TCP and TLS services on the same port?

Justin Warren daedalus at eigenmagic.com
Fri Jun 10 01:06:57 EDT 2005

On Fri, 2005-06-10 at 11:19 +0800, Eric Hsu wrote:
> Hi all!
> I'm trying to write a server which listens on port 12345 for both TLS
> and normal TCP connections:
> The client first connects to the server:12345 over TLS to obtain a
> one-time share secret;
> then the client closes(?) the TLS connection and uses the share secret
> to communicate with the server:12345 over *normal TCP*.
> Could this be done? If it could, pls enlighten me with some sample
> code, BIG thanks!

That sounds a bit.. odd. TLS runs over the top of some sort of reliable
transport protocol, like TCP. A server would thus be listening for TCP
connections. What you do after the connection is accepted determines
whether you negotiate TLS, echo stuff back or do whatever else your
server does. If you've already negotiated a TLS connection and thus have
a secure communications channel, why would you want to turn it off and
go back to normal, unencrypted comms?

What is the problem you are trying to solve here?

I mean, in theory, yes, you could do what you're proposing. Why do you
want to, though?

Justin Warren <daedalus at eigenmagic.com>

More information about the Twisted-Python mailing list