RFC 2487

SMTP Service Extension for Secure SMTP over TLS

๐Ÿ“… published January 1999, from ietf

SMTP Service Extension for Secure SMTP over TLS ๐Ÿ’Œ

Okay bestie, this is RFC 2487 ๐ŸŽ€, from the Network Working Group โœจ. It was written by P. Hoffman of the Internet Mail Consortium ๐Ÿ’… and dated January 1999. It's a Standards Track document ๐Ÿ‘‘, so it's a real protocol spec, not just a chat about ideas.

Status of This Memo ๐Ÿ“

This document specifies an Internet standards track protocol for the Internet community ๐ŸŒˆ, and it requests discussion and suggestions for improvements ๐Ÿ’ฌ. For the standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1) ๐Ÿ“š. Distribution of this memo is unlimited ๐Ÿฆ‹.

Copyright (C) The Internet Society (1999). All Rights Reserved. ๐Ÿ’œ

1. Abstract โœจ

This doc describes an extension to the SMTP service ๐Ÿ“จ that lets an SMTP server and client use transport-layer security to get private, authenticated communication over the Internet ๐Ÿ”’. So SMTP agents can protect some or all of their communications from eavesdroppers and attackers ๐Ÿ•ต๏ธโ€โ™€๏ธ. Iconic. ๐Ÿ‘‘

2. Introduction ๐ŸŒธ

SMTP [RFC-821] servers and clients normally talk in the clear over the Internet ๐Ÿซฃ. A lot of the time, that traffic goes through one or more routers that neither side controls or trusts ๐Ÿš. An untrusted router like that could let a third party watch or change what the server and client are saying to each other ๐Ÿ˜ฌ.

There's also often a real need for two SMTP agents to verify each other's identities ๐Ÿชช. For example, a secure SMTP server might only accept communication from other SMTP agents it already knows ๐Ÿค. Or it might handle messages from a known agent differently than messages from one it doesn't know ๐Ÿง.

TLS [TLS], which you probably know better as SSL, is a popular way to give TCP communications privacy and authentication ๐Ÿ”. It's widely used with HTTP, and it's also being used to add security to lots of other common protocols that run over TCP ๐Ÿ’–.

2.1 Terminology ๐Ÿ“–

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC-2119] ๐Ÿง .

3. STARTTLS Extension ๐ŸŽ€

The STARTTLS extension to SMTP is set up like this ๐Ÿงš:

  1. the name of the SMTP service defined here is STARTTLS;
  2. the EHLO keyword value associated with the extension is STARTTLS;
  3. the STARTTLS keyword has no parameters;
  4. a new SMTP verb, STARTTLS, is defined;
  5. no additional parameters are added to any SMTP command.

4. The STARTTLS Keyword ๐Ÿฆ‹

The STARTTLS keyword is how the SMTP server tells the SMTP client that it allows TLS ๐Ÿ™Œ. It takes no parameters ๐Ÿซถ.

5. The STARTTLS Command ๐Ÿ’…

The format for the STARTTLS command is:

STARTTLS

with no parameters ๐ŸŒท.

After the client sends the STARTTLS command, the server replies with one of these reply codes ๐Ÿ“ฌ:

220 Ready to start TLS
501 Syntax error (no parameters allowed)
454 TLS not available due to temporary reason

Okay, this next part is a big deal ๐Ÿšจ. A publicly-referenced SMTP server MUST NOT require use of the STARTTLS extension in order to deliver mail locally ๐Ÿ™…โ€โ™€๏ธ. This rule stops the STARTTLS extension from wrecking the interoperability of the Internet's SMTP infrastructure ๐ŸŒ. A publicly-referenced SMTP server is an SMTP server that runs on port 25 of an Internet host listed in the MX record (or the A record if there's no MX record) for the domain name on the right-hand side of an Internet mail address ๐Ÿ“.

Any SMTP server may refuse to accept messages for relay based on authentication supplied during the TLS negotiation ๐Ÿšช. An SMTP server that is not publicly referenced may refuse to accept any messages for relay or local delivery based on authentication supplied during the TLS negotiation ๐Ÿ›‘.

An SMTP server that is not publicly referenced may choose to require that the client do a TLS negotiation before accepting any commands ๐Ÿ”‘. In that case, the server SHOULD return this reply code:

530 Must issue a STARTTLS command first

to every command other than NOOP, EHLO, STARTTLS, or QUIT ๐Ÿ™ˆ. If the client and server are using the ENHANCEDSTATUSCODES ESMTP extension [RFC-2034], the status code to be returned SHOULD be 5.7.0 ๐ŸŒˆ.

After receiving a 220 response to a STARTTLS command, the client SHOULD start the TLS negotiation before sending any other SMTP commands ๐Ÿƒโ€โ™€๏ธ.

If the SMTP client is using pipelining as defined in RFC 1854, the STARTTLS command must be the last command in a group ๐Ÿ“.

5.1 Processing After the STARTTLS Command ๐Ÿ”

After the TLS handshake is done, both parties MUST immediately decide whether or not to keep going, based on the authentication and privacy they got ๐Ÿง. The SMTP client and server may decide to move ahead even if the TLS negotiation ended with no authentication and/or no privacy ๐Ÿคทโ€โ™€๏ธ. That's because most SMTP services run with no authentication and no privacy ๐Ÿ’ญ. But some SMTP clients or servers might only want to continue if a certain level of authentication and/or privacy was achieved ๐Ÿ›ก๏ธ.

If the SMTP client decides the level of authentication or privacy isn't high enough to continue, it SHOULD issue an SMTP QUIT command right after the TLS negotiation is complete ๐Ÿ‘‹. If the SMTP server decides the level of authentication or privacy isn't high enough, it SHOULD reply to every SMTP command from the client (other than a QUIT command) with the 554 reply code ๐Ÿšซ. It can include a text string like "Command refused due to lack of security" ๐Ÿฅ€.

Whether to believe the other party's authenticity in a TLS negotiation is a local decision ๐Ÿ . Still, here are some general rules for making that call ๐Ÿ’ก:

  • An SMTP client would probably only want to authenticate an SMTP server whose server certificate has a domain name matching the domain name the client thought it was connecting to ๐ŸŽฏ.
  • A publicly-referenced SMTP server would probably want to accept any certificate from an SMTP client ๐Ÿช„, and it might want to put distinguishing information about the certificate in the Received header of messages that were relayed or submitted from the client ๐Ÿ“.

5.2 Result of the STARTTLS Command ๐ŸŒŸ

When the TLS handshake finishes, the SMTP protocol resets to its initial state (the state SMTP is in after a server sends a 220 service ready greeting) ๐Ÿ”„. The server MUST discard any knowledge it got from the client that didn't come from the TLS negotiation itself, like the argument to the EHLO command ๐Ÿ—‘๏ธ. The client MUST discard any knowledge it got from the server that didn't come from the TLS negotiation itself, like the list of SMTP service extensions ๐Ÿงน. The client SHOULD send an EHLO command as its first command after a successful TLS negotiation ๐Ÿ’Œ.

The list of SMTP service extensions returned in response to an EHLO command received after the TLS handshake MAY be different from the list returned before it ๐ŸŽญ. For example, an SMTP server might not want to advertise support for a particular SASL mechanism [SASL] unless the client sent an appropriate client certificate during the TLS handshake ๐Ÿชช.

Both the client and the server MUST know whether a TLS session is active ๐Ÿ‘€. A client MUST NOT try to start a TLS session if one is already active ๐Ÿ™…โ€โ™€๏ธ. A server MUST NOT return the TLS extension in response to an EHLO command received after a TLS handshake has completed ๐Ÿšซ.


To be continued in part 2! ๐ŸŒˆโœจ

A. References ๐Ÿ“š

okay so this is the bibliography bit, and it's giving "receipts for everything" ๐Ÿ’… every doc this one leans on is listed here so you can go read them yourself ๐Ÿค“

  • [RFC-821] Postel, J., "Simple Mail Transfer Protocol", RFC 821, August 1982. ๐Ÿ“ฎ
  • [RFC-1869] Klensin, J., Freed, N, Rose, M, Stefferud, E. and D. Crocker, "SMTP Service Extensions", STD 10, RFC 1869, November 1995. โœจ
  • [RFC-2034] Freed, N., "SMTP Service Extension for Returning Enhanced Error Codes", RFC 2034, October 1996. ๐ŸŽ€
  • [RFC-2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. ๐Ÿ”ฅ
  • [SASL] Myers, J., "Simple Authentication and Security Layer (SASL)", RFC 2222, October 1997. ๐Ÿฆ‹
  • [SMTP-AUTH] "SMTP Service Extension for Authentication", Work in Progress. ๐Ÿšง
  • [TLS] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC 2246, January 1999. ๐Ÿ”

B. Author's Address ๐Ÿก

this is where you can find the author, Paul Hoffman, at the Internet Mail Consortium ๐Ÿ’–

Paul Hoffman
Internet Mail Consortium
127 Segre Place
Santa Cruz, CA  95060

Phone: (831) 426-9827
EMail: phoffman@imc.org

okay, legal bit, but make it cute ๐ŸŽ€ the Internet Society owns the copyright (C) for 1999, and all rights are reserved, but it's honestly super generous lowkey ๐Ÿซถ

so basically you're allowed to copy this doc and hand it out to people ๐Ÿ“„ you can also make derivative works that comment on it, explain it, or help people actually implement it, and you can prepare, copy, publish, and distribute those too, in whole or in part, with no restriction at all โœจ the one catch is that the copyright notice and this paragraph have to stay on every copy and every derivative work ๐Ÿ™

the doc itself cannot be modified in any way, though ๐Ÿ™ˆ that means no removing the copyright notice and no removing references to the Internet Society or other Internet organizations. the exceptions are when you need it for developing Internet standards, in which case you have to follow the copyright procedures in the Internet Standards process, or when you need to translate it into a language that isn't English ๐ŸŒธ

these permissions are perpetual, which is the forever kind of vibe ๐Ÿ’œ they will not be revoked by the Internet Society or its successors or assigns โœจ

last but not least, the doc and everything in it is provided on an "AS IS" basis ๐Ÿ’€ THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. so yeah, no guarantees, just vibes ๐ŸŒŸ

๐Ÿ“ฆ where this page comes from