closure alert

closure alert

[2] closure alert は、 TLS接続を閉じることを表すメッセージです。 AlertDescription の値 close_notify (0) は、 closure alert を表します。

仕様書

プロトコル

[3] クライアントは、truncation attack の防止のため、 接続を終える旨を共有しなければなりません >>1closure alert (AlertDescription = close_notify (0) のメッセージ) をこれに用います。他の fatal alert を転送した場合を除き、クライアントは、接続の書き込み側を閉じる前に close_notify alert を送信する必要があります >>1

[6] close_notify alert は、送信者が当該接続においてそれ以上はメッセージを送らないことを意味します >>1クライアントのどちらから送信しても構いません >>1

[5] closure alert より後に受信したデータは、無視します >>1

[7] closure alert を受信したら、 close_notity alert を返送すると共に、直ちに接続を閉じ、書き残したものがあれば捨てなければなりません >>1

[8] close_notify を先に送った側は、返送の到着を待たずに接続の読み込み側を閉じて構いません >>1TLS を使う応用プロトコルTLS が閉じられた後に下位の輸送路を使ってデータを転送する場合には、 TLS接続が閉じられたと応用プロトコル側に通知するのは close_notify alert が返送された後としなければなりません >>1応用プロトコルがそれ以上データを転送せずに下位の輸送路を閉じるだけの場合には、 close_notify alert の返送を待たずとも構いません >>1

[4] 接続を正しく閉じることに失敗しても、TLSセッション再開することを妨げるものではありません >>1

[12] これは TLS/1.0 から TLS/1.1 での仕様変更 >>1 ですが、 それ以前から既にそのような実装がなされていた >>1 ようです。
[13] error alert の場合は、TLSセッション再開は禁止されています。

[11] alert levelclosure alert では無視されるようです。

応用

[9] アプリケーション層プロトコルは、 TLS を使う場合に closure alert との関係 (どのタイミングで closure alert を送信するのか、 closure alert を受信した場合にアプリケーション層プロトコル側でどうエラー処理するのか、 TLS より下の層のプロトコル接続を閉じるタイミングなど) を規定する必要があります。

[10] 例えば RFC 2818HTTPS における取り扱いを規定しています。
[14] Issue 244260 - chromium - Security: TLS Truncation attack on HTTP headers, including cookie flags - An open-source project to help move the web forward. - Google Project Hosting ( 版) https://code.google.com/p/chromium/issues/detail?id=244260

Requiring close_notify isn't possible because so many sites don't send it

[15] Issue 244260 - chromium - Security: TLS Truncation attack on HTTP headers, including cookie flags - An open-source project to help move the web forward. - Google Project Hosting ( 版) https://code.google.com/p/chromium/issues/detail?id=244260

However, like all other browsers, it doesn't implement the mandatory TLS closure alert enforcement from TLS 1.1 to prevent truncation attacks at the transport layer.

[16] SSL / TLS: Is a server always required to respond to a close notify? - Information Security Stack Exchange ( 版) http://security.stackexchange.com/questions/82028/ssl-tls-is-a-server-always-required-to-respond-to-a-close-notify

For example, https://www.oracle.com sends the close notify as I expect it, but https://www.google.com does not - it just closes the connection after my app sends the close notify.

[17] SSL / TLS: Is a server always required to respond to a close notify? - Information Security Stack Exchange ( 版) http://security.stackexchange.com/questions/82028/ssl-tls-is-a-server-always-required-to-respond-to-a-close-notify

OpenSSL, and thus implementations based on OpenSSL (clients and server), tend to no longer send close_notify messages; they just drop the connection. The main reason is that in existing Web servers and clients, connections are managed in a pool that closes them after some inactivity delay; that pool manages low-level sockets and has no notion of what SSL could be; thus, the SSL layer has no way to send (or wait for) an explicit close_notify.

[18] ChromeIE は、正常時も異常時も、 alert を送らないで TCP接続を閉じるようです。

[19] Firefox は正常時は close_notify、異常時は適当なエラーの alert を送って閉じるようです。 相手の TLS alert は待たずにTCPを閉じるようです。

[20] tls - how can i bypass close_notify in ssl in firefox? - Information Security Stack Exchange ( 版) http://security.stackexchange.com/questions/63719/how-can-i-bypass-close-notify-in-ssl-in-firefox

Both GnuTLS and CDSA (Adium's SSL plugin) check whether a TLS connection has been closed properly by checking if the server sent a close_notify alert first. [https://bugzilla.mozilla.org/show_bug.cgi?id=508698 NSS doesn't]. If that alert wasn't sent, GnuTLS and CDSA consider it a fatal error, which for the HTTPS handler means the response is completely discarded. That's what's happening here with Yahoo: their HTTPS server closes the connection without sending close_notify first.

[21] 508698 – SSL_SecureRecv returns 0 rather than an error if the peer closes the TCP connection without sending an SSL close_notify alert ( 版) https://bugzilla.mozilla.org/show_bug.cgi?id=508698

[22] /docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html (OpenSSL Foundation, Inc.著, ) https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_quiet_shutdown.html