indimail / indimail-mta

qmail fork with IPV6, TLS, DANE, DKIM, SRS2, SPF, daemontools, qmailanalog, mess822, & ucspi-tcp
https://github.com/indimail/indimail-mta/wiki/0-IndiMail-Wiki
GNU General Public License v3.0
12 stars 3 forks source link

Add SSL/TLS encryption in tcpclient #10

Closed mbhangui closed 3 years ago

mbhangui commented 3 years ago

This PR adds SSL/TLS encryption in tcpclient. A client program dotls has been included which reads stdin, writes to fd 7 and reads fd 6 and writes to stdout

This PR also adds client mode operation when prog is omitted. In this case tcpclient passes data from fd 0 (stdin) to the network and data from the network to fd 1 (stdout). This makes it work like telnet(1), ssh(1) and other programs

Examples

  1. Connect to port 25

    $ tcpclient 0 25
    220 indimail.org (NO UCE) ESMTP IndiMail 1.238 Wed, 3 Mar 2021 18:08:10 +0530
    ehlo
    250-indimail.org [::1]
    250-PIPELINING
    250-8BITMIME
    250-SIZE 10000000
    250-ETRN
    250-STARTTLS
    250 HELP
    quit
    221 indimail.org closing connection
  2. Connect to port SMTPS port on 465 using IPv6

    $ tcpclient -n "" ::1 465
    220 indimail.org (NO UCE) ESMTP IndiMail 1.238 Wed, 3 Mar 2021 18:09:52 +0530
    ehlo
    250-indimail.org [::1]
    250-AUTH LOGIN PLAIN CRAM-MD5 CRAM-SHA1 CRAM-SHA256 CRAM-SHA512 CRAM-RIPEMD DIGEST-MD5
    250-AUTH=LOGIN PLAIN CRAM-MD5 CRAM-SHA1 CRAM-SHA256 CRAM-SHA512 CRAM-RIPEMD DIGEST-MD5
    250-PIPELINING
    250-8BITMIME
    250-SIZE 10000000
    250-ETRN
    250 HELP
    quit
    221 indimail.org closing connection
  3. Provide oppurtunistic TLS for notqmail/netqmail/qmail qmail-smtpd

    $ tcpserver -HR -v 0 5555 /usr/bin/dotls -n "" -s smtp /var/qmail/bin/qmail-smtpd
    tcpserver: status: 0/40 sql: 1
  4. Run tcpclient in client mode and issue STARTTLS command. This is similar to openssl s_client -starttls -crlf

    $ tcpclient -HRv -n "" -s smtp 0 5555
    tcpclient: connected to ::1 port 5555
    220 indimail.org ESMTP
    ehlo
    250-indimail.org
    250-PIPELINING
    250 8BITMIME
    help
    214 notqmail home page: https://notqmail.org
    quit
    221 indimail.org

Files modified tcpclient.c tcpserver.c tcpclient.9 tcpserver.9 Makefile .gitignore TARGETS

Files added tls.c tls.h dotls.c dotls.1