Commit abcdca91 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Postpone early data processing if CH replay detected

parent 5e59577e
......@@ -145,6 +145,7 @@ void Connection::disconnect() {
tls.sct_requested = false;
tls.early_data_finish = false;
tls.early_cb_called = false;
tls.postpone_early_data = false;
}
if (fd != -1) {
......@@ -456,7 +457,8 @@ int Connection::tls_handshake() {
// server waits for EndOfEarlyData and Finished message from
// client, which voids the purpose of 0-RTT data. The left
// over of handshake is done through write_tls or read_tls.
if ((tls.handshake_state == TLS_CONN_WRITE_STARTED ||
if (!tls.postpone_early_data &&
(tls.handshake_state == TLS_CONN_WRITE_STARTED ||
tls.wbuf.rleft()) &&
tls.earlybuf.rleft()) {
rv = 1;
......@@ -478,7 +480,8 @@ int Connection::tls_handshake() {
}
tls.early_data_finish = true;
// The same reason stated above.
if ((tls.handshake_state == TLS_CONN_WRITE_STARTED ||
if (!tls.postpone_early_data &&
(tls.handshake_state == TLS_CONN_WRITE_STARTED ||
tls.wbuf.rleft()) &&
tls.earlybuf.rleft()) {
rv = 1;
......
......@@ -94,6 +94,9 @@ struct TLSConnection {
bool early_data_finish;
// true if early_cb gets called.
bool early_cb_called;
// true if processing early data should be postponed until handshake
// finishes.
bool postpone_early_data;
};
struct TCPHint {
......
......@@ -613,9 +613,10 @@ int early_cb(SSL *ssl, int *al, void *arg) {
conn->tls.anti_replay_req = nullptr;
if (res.status_code != 0) {
// If we cannot add key/value, just disable 0-RTT early data.
// Note that memcached atomically adds key/value.
conn->tls.early_data_finish = true;
// If we cannot add key/value, just postpone processing 0-RTT
// early data until handshake finishes. Note that memcached
// atomically adds key/value.
conn->tls.postpone_early_data = true;
}
conn->tls.handshake_state = TLS_CONN_NORMAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment