From 634af77a06c6e081b8e59a3dff48d40c042e3177 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 1 Feb 2019 15:45:42 -0800 Subject: [PATCH] deps: Remove EOED when SSL_MODE_QUIC_HACK is enabled Ported from https://github.com/tatsuhiro-t/openssl/commit/920a331423f69f14b4871e35b476ea4fd573993a PR-URL: https://github.com/nodejs/quic/pull/6 Reviewed-By: Daniel Bevenius --- deps/openssl/openssl/ssl/ssl_lib.c | 6 ++++++ deps/openssl/openssl/ssl/statem/statem_clnt.c | 3 ++- deps/openssl/openssl/ssl/statem/statem_srvr.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/deps/openssl/openssl/ssl/ssl_lib.c b/deps/openssl/openssl/ssl/ssl_lib.c index 092c67d189..aad2774084 100644 --- a/deps/openssl/openssl/ssl/ssl_lib.c +++ b/deps/openssl/openssl/ssl/ssl_lib.c @@ -1807,6 +1807,12 @@ int SSL_read_early_data(SSL *s, void *buf, size_t num, size_t *readbytes) ret = SSL_accept(s); if (ret <= 0) { /* NBIO or error */ + if ((s->mode & SSL_MODE_QUIC_HACK) + && s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { + *readbytes = 0; + return SSL_READ_EARLY_DATA_FINISH; + } + s->early_data_state = SSL_EARLY_DATA_ACCEPT_RETRY; return SSL_READ_EARLY_DATA_ERROR; } diff --git a/deps/openssl/openssl/ssl/statem/statem_clnt.c b/deps/openssl/openssl/ssl/statem/statem_clnt.c index 87800cd835..09d10a5240 100644 --- a/deps/openssl/openssl/ssl/statem/statem_clnt.c +++ b/deps/openssl/openssl/ssl/statem/statem_clnt.c @@ -450,7 +450,8 @@ static WRITE_TRAN ossl_statem_client13_write_transition(SSL *s) return WRITE_TRAN_CONTINUE; case TLS_ST_PENDING_EARLY_DATA_END: - if (s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { + if (!(s->mode & SSL_MODE_QUIC_HACK) + && s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { st->hand_state = TLS_ST_CW_END_OF_EARLY_DATA; return WRITE_TRAN_CONTINUE; } diff --git a/deps/openssl/openssl/ssl/statem/statem_srvr.c b/deps/openssl/openssl/ssl/statem/statem_srvr.c index d454326a99..54897faff4 100644 --- a/deps/openssl/openssl/ssl/statem/statem_srvr.c +++ b/deps/openssl/openssl/ssl/statem/statem_srvr.c @@ -57,7 +57,8 @@ static int ossl_statem_server13_read_transition(SSL *s, int mt) return 1; } break; - } else if (s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { + } else if (!(s->mode & SSL_MODE_QUIC_HACK) + && s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { if (mt == SSL3_MT_END_OF_EARLY_DATA) { st->hand_state = TLS_ST_SR_END_OF_EARLY_DATA; return 1; @@ -945,6 +946,15 @@ WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst) SSL3_CC_APPLICATION | SSL3_CHANGE_CIPHER_SERVER_WRITE)) /* SSLfatal() already called */ return WORK_ERROR; + + if ((s->mode & SSL_MODE_QUIC_HACK) + && s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) { + s->early_data_state = SSL_EARLY_DATA_FINISHED_READING; + if (!s->method->ssl3_enc->change_cipher_state( + s, SSL3_CC_HANDSHAKE | SSL3_CHANGE_CIPHER_SERVER_READ)) + /* SSLfatal() already called */ + return WORK_ERROR; + } } break;