# HG changeset patch # User Sergey Kandaurov # Date 1626955237 -10800 # Node ID 7f29db5294bdd52a8572cef7a24e57bc5ac70bd4 # Parent 8ab0d609af09c7cce034826ddd178757c880a568 QUIC: avoid processing 1-RTT with incomplete handshake in OpenSSL. OpenSSL is known to provide read keys for an encryption level before the level is active in TLS, following the old BoringSSL API. In BoringSSL, it was then fixed to defer releasing read keys until QUIC may use them. diff --git a/src/event/quic/ngx_event_quic.c b/src/event/quic/ngx_event_quic.c --- a/src/event/quic/ngx_event_quic.c +++ b/src/event/quic/ngx_event_quic.c @@ -918,6 +918,20 @@ ngx_quic_process_payload(ngx_connection_ return NGX_DECLINED; } +#if !defined (OPENSSL_IS_BORINGSSL) + /* OpenSSL provides read keys for an application level before it's ready */ + + if (pkt->level == ssl_encryption_application + && SSL_quic_read_level(c->ssl->connection) + < ssl_encryption_application) + { + ngx_log_error(NGX_LOG_INFO, c->log, 0, + "quic no %s keys ready, ignoring packet", + ngx_quic_level_name(pkt->level)); + return NGX_DECLINED; + } +#endif + pkt->keys = qc->keys; pkt->key_phase = qc->key_phase; pkt->plaintext = buf;