🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #246012

Re: [tin] Automatic Authentication with Stunnel

#246012
From: VanguardLH
Date: Fri, 24 Jun 2011 19:58
149 lines
8647 bytes
John F. Morse wrote:

> I use tin from time to time. I was using it to access a non-SSL/TLS 
> server, but using authentication (tin -rA).
> 
> IIRC, I didn't need to enter my username and password because it was in 
> the ~/.tin/.newsauth file.
> 
> Now I'm accessing a different server that requires SSL/TLS. I have two 
> choices: one going through a server with Stunnel 3.x running, and the 
> other is running Stunnel4 on the same host where I'm running tin version 
> 1.9.2.
> 
> I've moved to the local Stunnel route and it is working fine, except I 
> have to enter my username (or take the default), and then enter the 
> password on every launch.
> 
> Perhaps my memory has gone really bad, and I've always had to manually 
> enter the password? :-\
> 
> I have four different entries in the ~/.tin/.newsauth file but none seem 
> to be sufficient. They are of this syntax, munged of course:
> 
> localhost password username
> localhost.FQDN password username
> server password username
> server.FQDN password username
> 
> Any help would be appreciated.

It's been a long time since I last use sTunnel (and that was on Windows
to give me SSL access to Gmail because SpamPal doesn't support SSL - I
quit using SpamPal so didn't need sTunnel).  I think it was about 2
years, or more, since I last used it.  As I recall, you configure your
client so the server it specifies is the sTunnel proxy but you also give
your login credentials.  That way, your client connects to the proxy and
gives it the login username and password.  You configure sTunnel to
where it connects.  So it connects there and then passes on the login
credentials.

http://spampal.sourceforge.net/usermanual/servers/stunnel/stunnel.htm

In stunnel.conf, you configure it to accept inbound connects on a port.
If you have multiple email servers to which it will connect, you have to
define a different inbound port for each server.  So if you have 5 email
accounts that you want to poll, each using SSL, then you have to define
5 inbound ports in sTunnel.  That's because each inbound port defines
one e-mail server to which sTunnel will connect.  You have to specify
the correct protocol for the inbound port on sTunnel (POP, IMAP, SMTP)
so you match it up with the protocol you specify in your client.

In your client (tin), you would define the server as the local proxy for
sTunnel.  If you are running sTunnel, you use localhost or 127.0.0.1 to
identify the server (which is now the local proxy).  In your client for
the username and password fields, you specify in the user/account field
both your username (for login) and the local proxy and its port, as in:

  <acctUsername>@127.0.0.1:<stunnelInPort>

If you configured sTunnel to accept inbound connect on port 1109 (that
then goes to a specific email server) and if your username was JohnM and
your password was 123456 then you configure your client would use:

  Account/User: johnm@127.0.0.1:1109
  Password:     123456 (shown as asterisks)

The password field in your client contains the login password.  Your
client connects to 127.0.0.1 (sTunnel proxy).  The account in your
client specifies in the User/Account field what is your login username,
the server again but along with its port.  So the client connects to
127.0.0.1 on port 1109 which is sTunnel and gives it the username.  The
client passes the password to the same proxy (sTunnel).  Since the
inbound port on sTunnel is associated with a particular protocol, the
proper handshaking is performed for sTunnel to grab the username and
password from the client's connect.  sTunnel then connects to the server
that you specified in its config file for that inbound port and passes
on the username and password using the same protocol as was defined for
that inbound port (so the protocol defined on the inbound port has to
match the protocol used at the email server).

sTunnel knows to where its outbound connect (the email server) by what
you define for an inbound port in its config file.  What protocol is
used by the inbound port (to the client and then to the email server) is
defined by under what section in the config file you put the definition.
Since the inbound port on sTunnel defines to where it connects, you
change the Server fields (POP, IMAP, SMTP) in your client to point at
the sTunnel proxy (127.0.0.1 or localhost).  You modify the User field
in your client to specify your username, ampersand, sTunnel proxy, and
its inbound port.  You leave the Password field in your client the same.

The instuctions above were for getting and sending emails through
sTunnel so you could use SSL with a client that doesn't support it.
There is no mention of an "[NNTP]" section in sTunnel.  It wasn't clear
from your post if you were looking to use SSL connects for e-mail
sending and receiving or for NNTP posting and reading.  Although not
that clear, the service types you can define are defined at:

http://www.stunnel.org/static/stunnel.html#configuration_file

nntp is listed as a supported protocol; however, there appears a
difference between version 4 (in the SpamPal version of using sTunnel)
and the version 8 manual.  In the past, you use "[imaps]" to specify a
block of parameters used for an inbound IMAP port in sTunnel (that then
used IMAPS to connect to the email server).  Their examples suck.
Notice they don't even tell you the name of the configuration file until
almost at the end of the documentation in where you are going to specify
all those parameters previously defined.  Their documentation is written
more like an Engineering Spec than a Functional Spec.

In version 4, you'd define a block in stunnel.conf for IMAPS like:

imaps]
accept = 127.0.0.1:8143
delay = yes
connect = imaps.myisp.com:993

Now it looks like you have to use something like:

[stunnel.imap]
protocol = imap
accept = 127.0.0.1:8143
delay = yes
connect = imaps.myisp.com:993

I had thought "[imaps]" was the protocol used by the block but instead
it's just the name for that block of parameters.  The parameter block
defined a "service name" in sTunnel.  So you could have:

[myisp-imaps]
accept = 127.0.0.1:8143
delay = yes
connect = imaps.myisp.com:993

I suspect the protocol parameter wasn't needed in my prior use of
sTunnel becaue I used a common outbound port (between sTunnel and the
email server).  That is, if I used a common port (which is what the
email server is likely to also use) then that port identified the
protocol to be used, as mentioned at:

http://www.stunnel.org/?page=faq
under "What are the offical SSL ports?" section

Since I see "nntps" in this list and also as a protocol mentioned in
their documentation then you should be able to use sTunnel for both
email and newsgroups; however, under protocol=nntp, it says "This
protocol is only supported in client mode."  I don't know what that
means versus "server mode".  To me, the proxy is always the server to
your email/nntp client but it is the client to the email/nntp server to
which it connects.
Technical Details
Message-ID: <iu2q4p$5vh$1@news.albasani.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!news.albasani.net!.POSTED!not-for-mail
References: <iu2hn0$bvk$1@n102.xanadu-bbs.net>

Show Full Headers
Complete Article Headers
Message-ID: <iu2q4p$5vh$1@news.albasani.net>
Subject: Re: [tin] Automatic Authentication with Stunnel
Date: Fri, 24 Jun 2011 14:58:58 -0500
From: VanguardLH <V@nguard.LH>
References: <iu2hn0$bvk$1@n102.xanadu-bbs.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!num2.nntp.dca.giganews.com!num1.nntp.dca.giganews.com!number.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!news.albasani.net!.POSTED!not-for-mail
Newsgroups: news.software.readers
Organization: 0.35MOA sniper at loose in Usenet
Lines: 149
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.albasani.net
 SCLl8731h4JyuvENHgfFtbV4JyGF0hgx7OPYrSZ6TJpgJ1OeJPWffG6GqkjeR6oQQGr826edawup0q4ntA/ujA==
NNTP-Posting-Date: Fri, 24 Jun 2011 19:56:09 +0000 (UTC)
Injection-Info: news.albasani.net;
 logging-data="BADb2s5F4NgDDwzeqr5ifPQej9gD5aA2Nl63VGVsElgJKrh+WCTq0QIWdvTombIY0pqY5AL8wKjt/zIRlDyP60eUmCcRkKWFTNlUWBimB8+K5KA2bJCNJWTJyWpz2F5R";
 mail-complaints-to="abuse@albasani.net"
Keywords: VanguardLH VLH811
User-Agent: 40tude_Dialog/2.0.15.84
Cancel-Lock: sha1:ydhBXqGPvekrohF23UteRAyayho=
X-MOTD: It is wiser to remain silent and let others ponder your ignorance than
 to speak and remove all doubt