[Oberon] Revision of OpenSMTP(...) in Oberon.Mail.Mod.

Joerg joerg.straube at iaeth.ch
Sun Apr 30 08:10:54 CEST 2023


Background info:
In RFC3207 (2002) the use of TLS encryption was added to SMTP; to change from TCP to TLS the command STARTTLS was added. RFC8314 (2018) recommends the use of „Implicit TLS“ iso STARTTLS.

In Oberon, Mail uses the modules NetSystem and NetTools providing basic TCP connectivity.
Those modules would have to be enhanced by adding TLS encryption to TCP.

One idea how this could be done:
- write a new module TLS.Mod that implements encryption according to RFC5246 (quite some work)
- add a TLS flag to the type NetTool.SessionDesc
- All procedures in NetSystem/NetTools check this flag and if set, must encrypt the arguments by calling TLS before sending the arguments to the TCP connection.
- When opening the mail session towards port 465, set the TLS flag of the session.

br
Jörg

> Am 29.04.2023 um 19:54 schrieb peter at easthope.ca:
> 
> Hi,
> 
> In A2, Oberon.Mail.Mod has OpenSMTP(...).
> https://gitlab.inf.ethz.ch/felixf/oberon/-/blob/main/source/Oberon.Mail.Mod
> 
> The module is also in the wikibook.
> https://en.wikibooks.org/wiki/Oberon/A2/Oberon.Mail.Mod
> 
> OpenSMTP was inherited from ETH Oberon.  Written when SMTP without
> authentication was routine.
> 
> I'm revising the procedure with two objectives.
> (1) Remove an unfavourable RETURN.
> (2) Add capability for AUTH PLAIN.
> 
>    (* SMTP should connect inside a TLS tunnel connected to smarthost port 465. *)
>    PROCEDURE OpenSMTP1*(VAR S: SMTPSession; host, user, passwd, from: ARRAY OF CHAR; port: SIGNED16);
>    BEGIN
>        IF trace THEN
>            Texts.WriteString(W, "--- SMTP"); Texts.WriteLn(W);
>            Texts.Append(Oberon.Log, W.buf)
>        END;
>        IF (port <= 0) OR (port >= 10000) THEN
>            port := AltSMTPPort
>        END;
>        NEW(S);
>        S.res := NetTools.Failed; S.C := NIL; S.S := NIL;
>        IF (host[0] = "<") OR (host[0] = 0X) THEN
>            S.reply := "no smtp-host specified"
>        ELSE (* smtp-host name available *)
>            IF ~NetTools.Connect(S.C, port, host, TRUE) THEN
>                S.reply := "no connection"
>            ELSE
>                S.S := NetTools.OpenStream(S.C);
>                ReadResponse(S);
>                IF S.reply[0] # "2" THEN (* Server declined communication *)
>                    CloseSMTP(S)
>                ELSE (* Positive response from server *)
>                    IF (user[0] = 0X) OR (passwd[0] = 0X) THEN (* Authentication impossible *)
>                        SendCmd(S, "HELO", NetSystem.hostName);
>                        ReadResponse(S);
>                        IF S.reply[0] = "2" THEN (* Server cooperating *)
>                            COPY(from, S.from); S.res := NetTools.Done
>                        END
>                    ELSE (* user and passwd available; try to authenticate *)
>                        SendCmd(S, "EHLO", NetSystem.hostName);
>                        ReadResponse(S);
>                        IF S.reply[0] = "2" THEN (* Server cooperating *)
>                            SendCmd(S, "AUTH", "PLAIN <Base64 encoded user & password>");
>                            IF S.reply[0] = "2" THEN (* Authentication accepted *)
>                                COPY(from, S.from); S.res := NetTools.Done
>                            END
>                        END
>                    END
>                END
>            END
>        END
>    END OpenSMTP1;
> 
> Comments?  Suggestions?
> 
> Thx,            ... P.L.
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon


More information about the Oberon mailing list