[erlang-questions] Listen to SSL and normal TCP connections on the same port

Ingela Andin <>
Wed Apr 17 09:41:18 CEST 2013


Hi!

2013/4/17 pablo platt <>

> Hi,
>
> Is it possible to accept SSL connections and normal TCP connections on the
> same port?
> Maybe accept normal TCP connections. If the connection is SSL connection
> pass it to the ssl module  and if it is a normal TCP connection just handle
> the socket.
>

It is possible to upgrade a tcp socket to an ssl socket.

If it is possible, how can I distinct SSL from non SSL connections?
>

That is the hard part. You must have some scheme to negotiate the upgrade
with the client over plain tcp. (Like STARTTLS, HTTP Connect etc)


> How can I pass the socket to the ssl module?
>

ssl:ssl_accept(TcpSocket, SslOptions)  or ssl:connect(TcpSocket,
SslOptions)
make sure the socket is passive ({active, false}) before you make the call.

Regards Ingela Erlang/OTP team Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130417/6500d19c/attachment.html>


More information about the erlang-questions mailing list