Skip to content

Commit 9b680bd

Browse files
committed
MINOR: quic: OpenSSL 3.5 trick to support 0-RTT
For an unidentified reason, SSL_do_hanshake() succeeds at its first call when 0-RTT is enabled for the connection. This behavior looks very similar by the one encountered by AWS-LC stack. That said, it was documented by AWS-LC. This issue leads the connection to stop sending handshake packets after having release the handshake encryption level. In fact, no handshake packets could even been sent leading the handshake to always fail. To fix this, this patch simulates a "handshake in progress" state waiting for the application level read secret to be established by the TLS stack. This may happen only after the QUIC listener has completed/confirmed the handshake upon handshake CRYPTO data receipt from the peer.
1 parent 5413c76 commit 9b680bd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/quic_ssl.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,27 @@ static int qc_ssl_provide_quic_data(struct ncbuf *ncbuf,
874874
}
875875
#endif
876876

877+
#ifndef HAVE_OPENSSL_QUIC
877878
TRACE_PROTO("SSL handshake OK", QUIC_EV_CONN_IO_CB, qc, &state);
879+
#else
880+
/* Hack to support O-RTT with the OpenSSL 3.5 QUIC API.
881+
* SSL_do_handshake() succeeds at the first call. Why? |-(
882+
* This prevents the handshake CRYPTO data to be sent.
883+
* To overcome this, ensure one does not consider the handshake is
884+
* successful if the read application level secrets have not been
885+
* provided by the stack. This happens after having received the peer
886+
* handshake level CRYPTO data which are validated by the TLS stack.
887+
*/
888+
if (qc->li->bind_conf->ssl_conf.early_data &&
889+
(!qc->ael || !qc->ael->tls_ctx.rx.secret)) {
890+
TRACE_PROTO("SSL handshake in progress",
891+
QUIC_EV_CONN_IO_CB, qc, &state, &ssl_err);
892+
goto out;
893+
}
894+
else {
895+
TRACE_PROTO("SSL handshake OK", QUIC_EV_CONN_IO_CB, qc, &state);
896+
}
897+
#endif
878898

879899
/* Check the alpn could be negotiated */
880900
if (!qc->app_ops) {

0 commit comments

Comments
 (0)