Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/3 (ngtcp2 and quiche) and alt-svc support in CMake #5359

Closed
wants to merge 3 commits into from

Conversation

Lekensteyn
Copy link
Contributor

autotools leaves a mess in my source directories, obviously I am going to fix CMake support in order to test HTTP/3 changes :-)

I built nghttp3 and ngtcp2 with CMake (the latter requires ngtcp2/ngtcp2#240 - not needed for autotools) and:

PKG_CONFIG_PATH=/tmp/openssl/prefix/lib/pkgconfig:/tmp/nghttp3/prefix/lib/pkgconfig:/tmp/ngtcp2/prefix/lib/pkgconfig \
cmake -GNinja -DUSE_NGTCP2=1 ~/projects/curl

The curl+quiche+boringssl build was configured with:

# quiche
cargo build -v --release --features pkg-config-meta,qlog
mkdir -p deps/boringssl/lib && ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) deps/boringssl/lib/

# curl
PKG_CONFIG_PATH=/tmp/quiche/target/release \
cmake -GNinja ~/projects/curl \
    -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
    -DCMAKE_C_FLAGS=-fsanitize=address,undefined \
    -DUSE_QUICHE=1 -DENABLE_ALT_SVC=1 \
    -DOPENSSL_ROOT_DIR=/tmp/quiche/deps/boringssl \
    -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DCMAKE_USE_LIBSSH2=OFF

My local build works, curl -v --http3 https://cloudflare.com and curl --alt-svc altsvc.cache -vk https://cloudflare.com (twice) works. Now let's see whether Travis is happy.

@Lekensteyn
Copy link
Contributor Author

Yay, the ngtcp2 build passes in Travis CI! I just forgot to set -DUSE_QUICHE=1 for the quiche build though 🤦, trying again...

Add three new CMake Find modules (using the curl license, but I grant
others the right to apply the CMake BSD license instead).

This CMake config is simpler than the autotools one because it assumes
ngtcp2 and nghttp3 to be used together. Another difference is that this
CMake config checks whether QUIC is actually supported by the TLS
library (patched OpenSSL or boringssl) since this can be a common
configuration mistake that could result in build errors later.

Unlike autotools, CMake does not warn you that the features are
experimental. The user is supposed to already know that and read the
documentation. It requires a very special build environment anyway.

Tested with ngtcp2+OpenSSL+nghttp3 and quiche+boringssl, both built from
current git master. Use `LD_DEBUG=files src/curl |& grep need` to figure
out which features (libldap-2.4, libssh2) to disable due to conflicts
with boringssl.
Tested alt-svc with quiche. While at it, add missing MultiSSL reporting
(not tested).
To avoid an explosion of jobs, extend the existing CMake tests with
ngtcp2 and quiche support. macOS was previously moved to GitHub actions,
so the non-Linux case can be dropped.
@Lekensteyn
Copy link
Contributor Author

The quiche_conn_set_qlog_fd check was missing some CMAKE_REQUIRED_xxx settings, fixed. I verified locally that it works, but it needs cloudflare/quiche#507 or else detection will fail.

If really needed, I could define size_t and ssize_t macros, but as users typically use the latest version of quiche I did not bother.

@Lekensteyn
Copy link
Contributor Author

Lekensteyn commented May 9, 2020

I've also managed to get this to build on macOS. This does not require pkg-config unlike the autotools build:

cd quiche
cargo build --release --features pkg-config-meta,qlog
ln -sv target/release/libquiche.{a,dylib} ./
mkdir -p deps/boringssl/lib && ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) deps/boringssl/lib/
cd ..

cd curl
mkdir build && cd build
cmake -GNinja -DOPENSSL_ROOT_DIR=$PWD/../../quiche/deps/boringssl -DQUICHE_ROOT=$PWD/../../quiche .. -DUSE_QUICHE=1
ninja curl

Result:

$ src/curl --version
curl 7.71.0-DEV (Darwin) libcurl/7.71.0-DEV BoringSSL zlib/1.2.11 quiche/0.3.0
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTP3 HTTPS-proxy IPv6 Largefile libz NTLM SSL UnixSockets

$ src/curl -v --http3 https://cloudflare.com
*   Trying 104.17.175.85:443...
* Sent QUIC client Initial, ALPN: h3-27
* Connected to cloudflare.com (104.17.175.85) port 443 (#0)
* h3 [:method: GET]
...
< HTTP/3 301
...
* Connection #0 to host cloudflare.com left intact

For the record, info about the macOS environment (no custom patches, hence the qlog issue):

$ cmake ...
-- The C compiler identification is AppleClang 11.0.3.11030032
...
-- Found OpenSSL: .../quiche/deps/boringssl/lib/libcrypto.a
...
-- Found QUICHE: .../quiche/libquiche.dylib
-- Looking for SSL_CTX_set_quic_method
-- Looking for SSL_CTX_set_quic_method - found
-- Looking for quiche_conn_set_qlog_fd
-- Looking for quiche_conn_set_qlog_fd - not found
...
$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.15.4
BuildVersion:	19E287
$ git log --oneline --no-decorate -n4
50f9c30d3 travis: Add ngtcp2 and quiche tests for CMake
405234677 CMake: add ENABLE_ALT_SVC option
67e0ce052 CMake: add HTTP/3 support (ngtcp2+nghttp3, quiche)
92501a12a checksrc: close the .checksrc file handle when done reading
$ git -C ../quiche log --oneline --no-decorate -n1
85ca070 allow sending 0.5 RTT data when 0-RTT is used

@bagder bagder closed this in 5bfc874 May 10, 2020
@bagder
Copy link
Member

bagder commented May 10, 2020

Thanks @Lekensteyn. Do you think it would be valuable to document that build method in docs/HTTP3.md too or will it just get too crowded?

@Lekensteyn
Copy link
Contributor Author

@bagder I've a patch to simplify those instructions + simplify CI, I'll push it into #5370 for review since it is somewhat related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake HTTP/3 h3 or quic related
Development

Successfully merging this pull request may close these issues.

None yet

2 participants