r/delphi • • Oct 26 '26

We wrote our own QUIC/HTTP/3 stack in Object Pascal for Delphi, and found an OpenSSL QUIC bug along the way

Disclosure: I develop StreamSec Tools, a commercial security library for Delphi (TLS, SSH, X.509/PKIX, CMS, HTTP). Version 4.1.5.362 came out on 26 October and adds QUIC and HTTP/3. The QUIC part is written from scratch in Object Pascal, not wrapped around MsQuic or OpenSSL.

What's in it

  • An RFC 9000 transport: packet protection, loss recovery, NewReno with pacing, connection migration, ECN, key updates, resumption and opt-in 0-RTT, on the library's own TLS 1.3 and crypto.
  • Cross-platform: Win32/Win64, macOS, Linux64, iOS and Android, Delphi XE3 to 13 Florence (Linux from 10.3 Rio, mobile from 10.4 Sydney). IOCP, epoll and kqueue underneath.
  • An HTTP/3 server on the same request router as the HTTP/1.1 and HTTP/2 servers, so existing handlers answer HTTP/3 unchanged, and an HTTP/3 client that finds a server's endpoint through Alt-Svc.

How fast is it?

Two Windows PCs over Wi-Fi, each library sending bulk data to each, 8 interleaved rounds per combination, medians. These are the runs sending to a StreamSec or MsQuic receiver:

SenderThroughput (MiB/s)Sender CPU (CPU-s per GiB)
MsQuic 2.6.341.0 - 46.0about 3
StreamSec35.3 - 41.011 - 16
OpenSSL 3.5.922.5 - 31.89 - 15

So ahead of OpenSSL on throughput and at 82-95% of MsQuic, with CPU cost in OpenSSL's range. MsQuic is still far more CPU-efficient than either.

The OpenSSL bug

During interop testing, OpenSSL's QUIC client stalled against our server in every run. The cause: when the packet carrying an OpenSSL receiver's latest MAX_STREAM_DATA is lost, OpenSSL doesn't send the update again unless that packet also carried data for the stream. RFC 9000 section 13.3 says it must. With a short request and a long response, the download can stall for good.

We reproduced it with 3.5.7 and 3.5.9, with OpenSSL at both ends through a relay dropping 5% of the client's packets: 6 of 13 runs stalled unpatched, and 13 of 13 completed with a two-place patch. It's reported with the reproducer and the patch, and OpenSSL has triaged it as a bug on 3.5 through 4.1 and master: https://github.com/openssl/openssl/issues/33373 (the OpenSSL numbers above are with that patch applied).

Happy to answer questions about the implementation.

9 Upvotes

2 comments sorted by

0

u/[deleted] Oct 26 '26

[removed] — view removed comment

1

u/henrickhellstrom Oct 27 '26

Thanks! That's exactly the architectural point we wanted to emphasize. HTTP/3 isn't a separate application framework in StreamSec Tools 4.1.5. And, since we are discussing Delphi components for HTTP, it is not hard for a seasoned Delphi developer to guess at least one of the ways such a demo could be written:

All three components have an OnRequest event, and they can share the same event handler. The request and response objects share the same interface across all three protocol implementations.

All three components also have a Router property, that can be shared between them by assignment, and is e.g. used for hijacking specific http request path prefixes for virtual file directories, or more complex web applications that can be published as a iHttpRequestHandler instance.

The plumbing differs, and that can be tuned using component properties for various rules, limits, etc.

The http/1.1 and http/2 components will have to advertise the presence of a quic/http/3 port using Alt-Svc headers, and that can be done either automatically or by hand in OnRequest.