[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: TLS in Gopher



Good morning,


On Thu, 2018-03-01 at 08:50 +0000, Iain R. Learmonth wrote:
> Hi,
> 
> On 01/03/18 07:18, Alex Schroeder wrote:
> > Perhaps I'm wrong and it is in fact trivially easy? Can somebody post
> > some sample code, a few lines maybe, illustrating how it would work in a
> > simple Gopher server?
> 
> Accept connection
> Read a few bytes, enough to know if it's a TLS client hello
> If it's TLS:
>    Hand over to TLS library
> If it's not TLS:
>    Handle the query directly
> 
> This is not that hard.

Exactly.


> In Python you would use the socket.MSG_PEEK option on a recv() call to
> take a look at those bytes before passing it off to a TLS library or
> handling the request directly.

This is what everybody uses. The auto detection isn't anything new or
fancy. A lot software supports it.

Just for fun I implemented Gopher support in Icecast 2.5.x this morning.
It has some limitations: selectors always start with / (as they are the
same as on HTTP). There are also no menus as there are no templates for
menus. They can be added in web/ and admin/ directories later if needed.

If the listen socket is set to "auto" or "auto_no_plain" TLS mode it
will support TLS auto detection. If it is set to "rfc2818" the server
will expect TLS right from the start. RFC2817 mode ("rfc2817") is
currently not supported as I have not (yet) implemented
Upgrade-to-Gopher.

You can find gopher support in branch "ph3-gopher" in the official repo,
see: https://wiki.xiph.org/Icecast_Server/Git_workflow

Some examples:
$ printf "/example1.ogg\r\n" | openssl s_client -connect \
  localhost:8905 -quiet | ogg123 -
$ printf "/example1.ogg\r\n" | netcat localhost 8905 | ogg123 -


Have fun.


With best regards,

-- 
Philipp.
 (Rah of PH2)


Reply to: