SSL/TLS in Python using STARTTLS and ssl/ssltelnet and telnetlib

Colin McPhail colin.mcphail at mac.com
Thu Nov 7 05:18:30 EST 2019



> On 7 Nov 2019, at 03:24, Veek M <veek at dont-use-this.com> wrote:
> 
> Could someone suggest some introductory reading material that will allow 
> me to use 'telnetlib' with 'ssl' or 'ssltelnet'. 
> (currently using Pan since Knode is dropped on Debian)
> 
> I'm trying to write something that will download the NNTP headers over 
> TLS.
> 
> The idea is to 
> 1. telnet to port 119, send 'CAPABILITIES\r\n' using telnetlib
> 2. then switch to TLS using STARTTLS
> 3. I tried just connecting to port 119 using a new TLS connection NOT 
> OVER telnet and it didn't work. Apparently you need to pass the TLS 
> context to telnetlib or vice versa.
> ...

Any reason you're not using nntplib from the Python Standard Library? It supports the  STARTTLS command.

If you don't want to use nntplib you could look at its code to see how it works.

-- Colin



More information about the Python-list mailing list