This SHOULD only be done when the application knows (typically
through detecting HTTP message boundaries) that it has received all
the message data that it cares about.
As specified in [RFC2246], any implementation which receives a
connection close without first receiving a valid closure alert (a
"premature close") MUST NOT reuse that session. Note that a
premature close does not call into question the security of the data
already received, but simply indicates that subsequent data might
RFC 2818 HTTP Over TLS May 2000
have been truncated. Because TLS is oblivious to HTTP
request/response boundaries, it is necessary to examine the HTTP data
itself (specifically the Content-Length header) to determine whether
the truncation occurred inside a message or between messages.
2.2.1. Client Behavior
Because HTTP uses connection closure to signal end of server data,
client implementations MUST treat any premature closes as errors and
the data received as potentially truncated. While in some cases the
HTTP protocol allows the client to find out whether truncation took
place so that, if it received the complete reply, it may tolerate
such errors following the principle to "[be] strict when sending and
tolerant when receiving" [RFC1958], often truncation does not show in
the HTTP protocol data; two cases in particular deserve special note:
A HTTP response without a Content-Length header. Since data length
in this situation is signalled by connection close a premature
close generated by the server cannot be distinguished from a
spurious close generated by an attacker.
A HTTP response with a valid Content-Length header closed before
all data has been read. Because TLS does not provide document
oriented protection, it is impossible to determine whether the
server has miscomputed the Content-Length or an attacker has
truncated the connection.
There is one exception to the above rule. When encountering a
premature close, a client SHOULD treat as completed all requests for
which it has received as much data as specified in the Content-Length
header.
A client detecting an incomplete close SHOULD recover gracefully. It
MAY resume a TLS session closed in this fashion.
Clients MUST send a closure alert before closing the connection.
Clients which are unprepared to receive any more data MAY choose not
to wait for the server's closure alert and simply close the
connection, thus generating an incomplete close on the server side.
2.2.2. Server Behavior
RFC 2616 permits an HTTP client to close the connection at any time,
and requires servers to recover gracefully. In particular, servers
SHOULD be prepared to receive an incomplete close from the client,
since the client can often determine when the end of server data is.
Servers SHOULD be willing to resume TLS sessions closed in this
fashion.
RFC 2818 HTTP Over TLS May 2000
Implementation note: In HTTP implementations which do not use
persistent connections, the server ordinarily expects to be able to
signal end of data by closing the connection. When Content-Length is
used, however, the client may have already sent the closure alert and
dropped the connection.
Servers MUST attempt to initiate an exchange of closure alerts with
the client before closing the connection. Servers MAY close the
connection after sending the closure alert, thus generating an
incomplete close on the client side.
2.3. Port Number
The first data that an HTTP server expects to receive from the client
is the Request-Line production. The first data that a TLS server (and
hence an HTTP/TLS server) expects to receive is the ClientHello.
Consequently, common practice has been to run HTTP/TLS over a
separate port in order to distinguish which protocol is being used.
When HTTP/TLS is being run over a TCP/IP connection, the default port
is 443. This does not preclude HTTP/TLS from being run over another
transport. TLS only presumes a reliable connection-oriented data
stream.
2.4. URI Format
HTTP/TLS is differentiated from HTTP URIs by using the 'https'
protocol identifier in place of the 'http' protocol identifier. An
=2= |