1*6236dae4SAndroid Build Coastguard Worker<!-- 2*6236dae4SAndroid Build Coastguard WorkerCopyright (C) Daniel Stenberg, <[email protected]>, et al. 3*6236dae4SAndroid Build Coastguard Worker 4*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl 5*6236dae4SAndroid Build Coastguard Worker--> 6*6236dae4SAndroid Build Coastguard Worker 7*6236dae4SAndroid Build Coastguard Worker# HTTP3 (and QUIC) 8*6236dae4SAndroid Build Coastguard Worker 9*6236dae4SAndroid Build Coastguard Worker## Resources 10*6236dae4SAndroid Build Coastguard Worker 11*6236dae4SAndroid Build Coastguard Worker[HTTP/3 Explained](https://http3-explained.haxx.se/en/) - the online free 12*6236dae4SAndroid Build Coastguard Workerbook describing the protocols involved. 13*6236dae4SAndroid Build Coastguard Worker 14*6236dae4SAndroid Build Coastguard Worker[quicwg.org](https://quicwg.org/) - home of the official protocol drafts 15*6236dae4SAndroid Build Coastguard Worker 16*6236dae4SAndroid Build Coastguard Worker## QUIC libraries 17*6236dae4SAndroid Build Coastguard Worker 18*6236dae4SAndroid Build Coastguard WorkerQUIC libraries we are using: 19*6236dae4SAndroid Build Coastguard Worker 20*6236dae4SAndroid Build Coastguard Worker[ngtcp2](https://github.com/ngtcp2/ngtcp2) 21*6236dae4SAndroid Build Coastguard Worker 22*6236dae4SAndroid Build Coastguard Worker[quiche](https://github.com/cloudflare/quiche) - **EXPERIMENTAL** 23*6236dae4SAndroid Build Coastguard Worker 24*6236dae4SAndroid Build Coastguard Worker[OpenSSL 3.2+ QUIC](https://github.com/openssl/openssl) - **EXPERIMENTAL** 25*6236dae4SAndroid Build Coastguard Worker 26*6236dae4SAndroid Build Coastguard Worker[msh3](https://github.com/nibanks/msh3) (with [msquic](https://github.com/microsoft/msquic)) - **EXPERIMENTAL** 27*6236dae4SAndroid Build Coastguard Worker 28*6236dae4SAndroid Build Coastguard Worker## Experimental 29*6236dae4SAndroid Build Coastguard Worker 30*6236dae4SAndroid Build Coastguard WorkerHTTP/3 support in curl is considered **EXPERIMENTAL** until further notice 31*6236dae4SAndroid Build Coastguard Workerwhen built to use *quiche* or *msh3*. Only the *ngtcp2* backend is not 32*6236dae4SAndroid Build Coastguard Workerexperimental. 33*6236dae4SAndroid Build Coastguard Worker 34*6236dae4SAndroid Build Coastguard WorkerFurther development and tweaking of the HTTP/3 support in curl happens in the 35*6236dae4SAndroid Build Coastguard Workermaster branch using pull-requests, just like ordinary changes. 36*6236dae4SAndroid Build Coastguard Worker 37*6236dae4SAndroid Build Coastguard WorkerTo fix before we remove the experimental label: 38*6236dae4SAndroid Build Coastguard Worker 39*6236dae4SAndroid Build Coastguard Worker - the used QUIC library needs to consider itself non-beta 40*6236dae4SAndroid Build Coastguard Worker - it is fine to "leave" individual backends as experimental if necessary 41*6236dae4SAndroid Build Coastguard Worker 42*6236dae4SAndroid Build Coastguard Worker# ngtcp2 version 43*6236dae4SAndroid Build Coastguard Worker 44*6236dae4SAndroid Build Coastguard WorkerBuilding curl with ngtcp2 involves 3 components: `ngtcp2` itself, `nghttp3` and a QUIC supporting TLS library. The supported TLS libraries are covered below. 45*6236dae4SAndroid Build Coastguard Worker 46*6236dae4SAndroid Build Coastguard Worker * `ngtcp2`: v1.2.0 47*6236dae4SAndroid Build Coastguard Worker * `nghttp3`: v1.1.0 48*6236dae4SAndroid Build Coastguard Worker 49*6236dae4SAndroid Build Coastguard Worker## Build with quictls 50*6236dae4SAndroid Build Coastguard Worker 51*6236dae4SAndroid Build Coastguard WorkerOpenSSL does not offer the required APIs for building a QUIC client. You need 52*6236dae4SAndroid Build Coastguard Workerto use a TLS library that has such APIs and that works with *ngtcp2*. 53*6236dae4SAndroid Build Coastguard Worker 54*6236dae4SAndroid Build Coastguard WorkerBuild quictls: 55*6236dae4SAndroid Build Coastguard Worker 56*6236dae4SAndroid Build Coastguard Worker % git clone --depth 1 -b openssl-3.1.4+quic https://github.com/quictls/openssl 57*6236dae4SAndroid Build Coastguard Worker % cd openssl 58*6236dae4SAndroid Build Coastguard Worker % ./config enable-tls1_3 --prefix=<somewhere1> 59*6236dae4SAndroid Build Coastguard Worker % make 60*6236dae4SAndroid Build Coastguard Worker % make install 61*6236dae4SAndroid Build Coastguard Worker 62*6236dae4SAndroid Build Coastguard WorkerBuild nghttp3: 63*6236dae4SAndroid Build Coastguard Worker 64*6236dae4SAndroid Build Coastguard Worker % cd .. 65*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.1.0 https://github.com/ngtcp2/nghttp3 66*6236dae4SAndroid Build Coastguard Worker % cd nghttp3 67*6236dae4SAndroid Build Coastguard Worker % git submodule update --init 68*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 69*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere2> --enable-lib-only 70*6236dae4SAndroid Build Coastguard Worker % make 71*6236dae4SAndroid Build Coastguard Worker % make install 72*6236dae4SAndroid Build Coastguard Worker 73*6236dae4SAndroid Build Coastguard WorkerBuild ngtcp2: 74*6236dae4SAndroid Build Coastguard Worker 75*6236dae4SAndroid Build Coastguard Worker % cd .. 76*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 77*6236dae4SAndroid Build Coastguard Worker % cd ngtcp2 78*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 79*6236dae4SAndroid Build Coastguard Worker % ./configure PKG_CONFIG_PATH=<somewhere1>/lib/pkgconfig:<somewhere2>/lib/pkgconfig LDFLAGS="-Wl,-rpath,<somewhere1>/lib" --prefix=<somewhere3> --enable-lib-only 80*6236dae4SAndroid Build Coastguard Worker % make 81*6236dae4SAndroid Build Coastguard Worker % make install 82*6236dae4SAndroid Build Coastguard Worker 83*6236dae4SAndroid Build Coastguard WorkerBuild curl: 84*6236dae4SAndroid Build Coastguard Worker 85*6236dae4SAndroid Build Coastguard Worker % cd .. 86*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 87*6236dae4SAndroid Build Coastguard Worker % cd curl 88*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 89*6236dae4SAndroid Build Coastguard Worker % LDFLAGS="-Wl,-rpath,<somewhere1>/lib" ./configure --with-openssl=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3> 90*6236dae4SAndroid Build Coastguard Worker % make 91*6236dae4SAndroid Build Coastguard Worker % make install 92*6236dae4SAndroid Build Coastguard Worker 93*6236dae4SAndroid Build Coastguard WorkerFor OpenSSL 3.0.0 or later builds on Linux for x86_64 architecture, substitute all occurrences of "/lib" with "/lib64" 94*6236dae4SAndroid Build Coastguard Worker 95*6236dae4SAndroid Build Coastguard Worker## Build with GnuTLS 96*6236dae4SAndroid Build Coastguard Worker 97*6236dae4SAndroid Build Coastguard WorkerBuild GnuTLS: 98*6236dae4SAndroid Build Coastguard Worker 99*6236dae4SAndroid Build Coastguard Worker % git clone --depth 1 https://gitlab.com/gnutls/gnutls.git 100*6236dae4SAndroid Build Coastguard Worker % cd gnutls 101*6236dae4SAndroid Build Coastguard Worker % ./bootstrap 102*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere1> 103*6236dae4SAndroid Build Coastguard Worker % make 104*6236dae4SAndroid Build Coastguard Worker % make install 105*6236dae4SAndroid Build Coastguard Worker 106*6236dae4SAndroid Build Coastguard WorkerBuild nghttp3: 107*6236dae4SAndroid Build Coastguard Worker 108*6236dae4SAndroid Build Coastguard Worker % cd .. 109*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.1.0 https://github.com/ngtcp2/nghttp3 110*6236dae4SAndroid Build Coastguard Worker % cd nghttp3 111*6236dae4SAndroid Build Coastguard Worker % git submodule update --init 112*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 113*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere2> --enable-lib-only 114*6236dae4SAndroid Build Coastguard Worker % make 115*6236dae4SAndroid Build Coastguard Worker % make install 116*6236dae4SAndroid Build Coastguard Worker 117*6236dae4SAndroid Build Coastguard WorkerBuild ngtcp2: 118*6236dae4SAndroid Build Coastguard Worker 119*6236dae4SAndroid Build Coastguard Worker % cd .. 120*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 121*6236dae4SAndroid Build Coastguard Worker % cd ngtcp2 122*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 123*6236dae4SAndroid Build Coastguard Worker % ./configure PKG_CONFIG_PATH=<somewhere1>/lib/pkgconfig:<somewhere2>/lib/pkgconfig LDFLAGS="-Wl,-rpath,<somewhere1>/lib" --prefix=<somewhere3> --enable-lib-only --with-gnutls 124*6236dae4SAndroid Build Coastguard Worker % make 125*6236dae4SAndroid Build Coastguard Worker % make install 126*6236dae4SAndroid Build Coastguard Worker 127*6236dae4SAndroid Build Coastguard WorkerBuild curl: 128*6236dae4SAndroid Build Coastguard Worker 129*6236dae4SAndroid Build Coastguard Worker % cd .. 130*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 131*6236dae4SAndroid Build Coastguard Worker % cd curl 132*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 133*6236dae4SAndroid Build Coastguard Worker % ./configure --with-gnutls=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3> 134*6236dae4SAndroid Build Coastguard Worker % make 135*6236dae4SAndroid Build Coastguard Worker % make install 136*6236dae4SAndroid Build Coastguard Worker 137*6236dae4SAndroid Build Coastguard Worker## Build with wolfSSL 138*6236dae4SAndroid Build Coastguard Worker 139*6236dae4SAndroid Build Coastguard WorkerBuild wolfSSL: 140*6236dae4SAndroid Build Coastguard Worker 141*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/wolfSSL/wolfssl.git 142*6236dae4SAndroid Build Coastguard Worker % cd wolfssl 143*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 144*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere1> --enable-quic --enable-session-ticket --enable-earlydata --enable-psk --enable-harden --enable-altcertchains 145*6236dae4SAndroid Build Coastguard Worker % make 146*6236dae4SAndroid Build Coastguard Worker % make install 147*6236dae4SAndroid Build Coastguard Worker 148*6236dae4SAndroid Build Coastguard WorkerBuild nghttp3: 149*6236dae4SAndroid Build Coastguard Worker 150*6236dae4SAndroid Build Coastguard Worker % cd .. 151*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.1.0 https://github.com/ngtcp2/nghttp3 152*6236dae4SAndroid Build Coastguard Worker % cd nghttp3 153*6236dae4SAndroid Build Coastguard Worker % git submodule update --init 154*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 155*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere2> --enable-lib-only 156*6236dae4SAndroid Build Coastguard Worker % make 157*6236dae4SAndroid Build Coastguard Worker % make install 158*6236dae4SAndroid Build Coastguard Worker 159*6236dae4SAndroid Build Coastguard WorkerBuild ngtcp2: 160*6236dae4SAndroid Build Coastguard Worker 161*6236dae4SAndroid Build Coastguard Worker % cd .. 162*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.2.0 https://github.com/ngtcp2/ngtcp2 163*6236dae4SAndroid Build Coastguard Worker % cd ngtcp2 164*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 165*6236dae4SAndroid Build Coastguard Worker % ./configure PKG_CONFIG_PATH=<somewhere1>/lib/pkgconfig:<somewhere2>/lib/pkgconfig LDFLAGS="-Wl,-rpath,<somewhere1>/lib" --prefix=<somewhere3> --enable-lib-only --with-wolfssl 166*6236dae4SAndroid Build Coastguard Worker % make 167*6236dae4SAndroid Build Coastguard Worker % make install 168*6236dae4SAndroid Build Coastguard Worker 169*6236dae4SAndroid Build Coastguard WorkerBuild curl: 170*6236dae4SAndroid Build Coastguard Worker 171*6236dae4SAndroid Build Coastguard Worker % cd .. 172*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 173*6236dae4SAndroid Build Coastguard Worker % cd curl 174*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 175*6236dae4SAndroid Build Coastguard Worker % ./configure --with-wolfssl=<somewhere1> --with-nghttp3=<somewhere2> --with-ngtcp2=<somewhere3> 176*6236dae4SAndroid Build Coastguard Worker % make 177*6236dae4SAndroid Build Coastguard Worker % make install 178*6236dae4SAndroid Build Coastguard Worker 179*6236dae4SAndroid Build Coastguard Worker# quiche version 180*6236dae4SAndroid Build Coastguard Worker 181*6236dae4SAndroid Build Coastguard Workerquiche support is **EXPERIMENTAL** 182*6236dae4SAndroid Build Coastguard Worker 183*6236dae4SAndroid Build Coastguard WorkerSince the quiche build manages its dependencies, curl can be built against the latest version. You are *probably* able to build against their main branch, but in case of problems, we recommend their latest release tag. 184*6236dae4SAndroid Build Coastguard Worker 185*6236dae4SAndroid Build Coastguard Worker## Build 186*6236dae4SAndroid Build Coastguard Worker 187*6236dae4SAndroid Build Coastguard WorkerBuild quiche and BoringSSL: 188*6236dae4SAndroid Build Coastguard Worker 189*6236dae4SAndroid Build Coastguard Worker % git clone --recursive -b 0.22.0 https://github.com/cloudflare/quiche 190*6236dae4SAndroid Build Coastguard Worker % cd quiche 191*6236dae4SAndroid Build Coastguard Worker % cargo build --package quiche --release --features ffi,pkg-config-meta,qlog 192*6236dae4SAndroid Build Coastguard Worker % ln -s libquiche.so target/release/libquiche.so.0 193*6236dae4SAndroid Build Coastguard Worker % mkdir quiche/deps/boringssl/src/lib 194*6236dae4SAndroid Build Coastguard Worker % ln -vnf $(find target/release -name libcrypto.a -o -name libssl.a) quiche/deps/boringssl/src/lib/ 195*6236dae4SAndroid Build Coastguard Worker 196*6236dae4SAndroid Build Coastguard WorkerBuild curl: 197*6236dae4SAndroid Build Coastguard Worker 198*6236dae4SAndroid Build Coastguard Worker % cd .. 199*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 200*6236dae4SAndroid Build Coastguard Worker % cd curl 201*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 202*6236dae4SAndroid Build Coastguard Worker % ./configure LDFLAGS="-Wl,-rpath,$PWD/../quiche/target/release" --with-openssl=$PWD/../quiche/quiche/deps/boringssl/src --with-quiche=$PWD/../quiche/target/release 203*6236dae4SAndroid Build Coastguard Worker % make 204*6236dae4SAndroid Build Coastguard Worker % make install 205*6236dae4SAndroid Build Coastguard Worker 206*6236dae4SAndroid Build Coastguard Worker If `make install` results in `Permission denied` error, you need to prepend 207*6236dae4SAndroid Build Coastguard Worker it with `sudo`. 208*6236dae4SAndroid Build Coastguard Worker 209*6236dae4SAndroid Build Coastguard Worker# OpenSSL version 210*6236dae4SAndroid Build Coastguard Worker 211*6236dae4SAndroid Build Coastguard WorkerQUIC support is **EXPERIMENTAL** 212*6236dae4SAndroid Build Coastguard Worker 213*6236dae4SAndroid Build Coastguard WorkerBuild OpenSSL 3.3.1: 214*6236dae4SAndroid Build Coastguard Worker 215*6236dae4SAndroid Build Coastguard Worker % cd .. 216*6236dae4SAndroid Build Coastguard Worker % git clone -b openssl-3.3.1 https://github.com/openssl/openssl 217*6236dae4SAndroid Build Coastguard Worker % cd openssl 218*6236dae4SAndroid Build Coastguard Worker % ./config enable-tls1_3 --prefix=<somewhere> --libdir=lib 219*6236dae4SAndroid Build Coastguard Worker % make 220*6236dae4SAndroid Build Coastguard Worker % make install 221*6236dae4SAndroid Build Coastguard Worker 222*6236dae4SAndroid Build Coastguard WorkerBuild nghttp3: 223*6236dae4SAndroid Build Coastguard Worker 224*6236dae4SAndroid Build Coastguard Worker % cd .. 225*6236dae4SAndroid Build Coastguard Worker % git clone -b v1.1.0 https://github.com/ngtcp2/nghttp3 226*6236dae4SAndroid Build Coastguard Worker % cd nghttp3 227*6236dae4SAndroid Build Coastguard Worker % git submodule update --init 228*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 229*6236dae4SAndroid Build Coastguard Worker % ./configure --prefix=<somewhere2> --enable-lib-only 230*6236dae4SAndroid Build Coastguard Worker % make 231*6236dae4SAndroid Build Coastguard Worker % make install 232*6236dae4SAndroid Build Coastguard Worker 233*6236dae4SAndroid Build Coastguard WorkerBuild curl: 234*6236dae4SAndroid Build Coastguard Worker 235*6236dae4SAndroid Build Coastguard Worker % cd .. 236*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 237*6236dae4SAndroid Build Coastguard Worker % cd curl 238*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 239*6236dae4SAndroid Build Coastguard Worker % LDFLAGS="-Wl,-rpath,<somewhere>/lib" ./configure --with-openssl=<somewhere> --with-openssl-quic --with-nghttp3=<somewhere2> 240*6236dae4SAndroid Build Coastguard Worker % make 241*6236dae4SAndroid Build Coastguard Worker % make install 242*6236dae4SAndroid Build Coastguard Worker 243*6236dae4SAndroid Build Coastguard WorkerYou can build curl with cmake: 244*6236dae4SAndroid Build Coastguard Worker 245*6236dae4SAndroid Build Coastguard Worker % cd .. 246*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 247*6236dae4SAndroid Build Coastguard Worker % cd curl 248*6236dae4SAndroid Build Coastguard Worker % cmake . -B bld -DCURL_USE_OPENSSL=ON -DUSE_OPENSSL_QUIC=ON 249*6236dae4SAndroid Build Coastguard Worker % cmake --build bld 250*6236dae4SAndroid Build Coastguard Worker % cmake --install bld 251*6236dae4SAndroid Build Coastguard Worker 252*6236dae4SAndroid Build Coastguard Worker If `make install` results in `Permission denied` error, you need to prepend 253*6236dae4SAndroid Build Coastguard Worker it with `sudo`. 254*6236dae4SAndroid Build Coastguard Worker 255*6236dae4SAndroid Build Coastguard Worker# msh3 (msquic) version 256*6236dae4SAndroid Build Coastguard Worker 257*6236dae4SAndroid Build Coastguard Worker**Note**: The msquic HTTP/3 backend is immature and is not properly functional 258*6236dae4SAndroid Build Coastguard Workerone as of September 2023. Feel free to help us test it and improve it, but 259*6236dae4SAndroid Build Coastguard Workerthere is no point in filing bugs about it just yet. 260*6236dae4SAndroid Build Coastguard Worker 261*6236dae4SAndroid Build Coastguard Workermsh3 support is **EXPERIMENTAL** 262*6236dae4SAndroid Build Coastguard Worker 263*6236dae4SAndroid Build Coastguard Worker## Build Linux (with quictls fork of OpenSSL) 264*6236dae4SAndroid Build Coastguard Worker 265*6236dae4SAndroid Build Coastguard WorkerBuild msh3: 266*6236dae4SAndroid Build Coastguard Worker 267*6236dae4SAndroid Build Coastguard Worker % git clone -b v0.6.0 --depth 1 --recursive https://github.com/nibanks/msh3 268*6236dae4SAndroid Build Coastguard Worker % cd msh3 && mkdir build && cd build 269*6236dae4SAndroid Build Coastguard Worker % cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 270*6236dae4SAndroid Build Coastguard Worker % cmake --build . 271*6236dae4SAndroid Build Coastguard Worker % cmake --install . 272*6236dae4SAndroid Build Coastguard Worker 273*6236dae4SAndroid Build Coastguard WorkerBuild curl: 274*6236dae4SAndroid Build Coastguard Worker 275*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 276*6236dae4SAndroid Build Coastguard Worker % cd curl 277*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 278*6236dae4SAndroid Build Coastguard Worker % ./configure LDFLAGS="-Wl,-rpath,/usr/local/lib" --with-msh3=/usr/local --with-openssl 279*6236dae4SAndroid Build Coastguard Worker % make 280*6236dae4SAndroid Build Coastguard Worker % make install 281*6236dae4SAndroid Build Coastguard Worker 282*6236dae4SAndroid Build Coastguard WorkerRun from `/usr/local/bin/curl`. 283*6236dae4SAndroid Build Coastguard Worker 284*6236dae4SAndroid Build Coastguard Worker## Build Windows 285*6236dae4SAndroid Build Coastguard Worker 286*6236dae4SAndroid Build Coastguard WorkerBuild msh3: 287*6236dae4SAndroid Build Coastguard Worker 288*6236dae4SAndroid Build Coastguard Worker % git clone -b v0.6.0 --depth 1 --recursive https://github.com/nibanks/msh3 289*6236dae4SAndroid Build Coastguard Worker % cd msh3 && mkdir build && cd build 290*6236dae4SAndroid Build Coastguard Worker % cmake -G 'Visual Studio 17 2022' -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 291*6236dae4SAndroid Build Coastguard Worker % cmake --build . --config Release 292*6236dae4SAndroid Build Coastguard Worker % cmake --install . --config Release 293*6236dae4SAndroid Build Coastguard Worker 294*6236dae4SAndroid Build Coastguard Worker**Note** - On Windows, Schannel is used for TLS support by default. If you 295*6236dae4SAndroid Build Coastguard Workerwith to use (the quictls fork of) OpenSSL, specify the `-DQUIC_TLS=openssl` 296*6236dae4SAndroid Build Coastguard Workeroption to the generate command above. Also note that OpenSSL brings with it an 297*6236dae4SAndroid Build Coastguard Workeradditional set of build dependencies not specified here. 298*6236dae4SAndroid Build Coastguard Worker 299*6236dae4SAndroid Build Coastguard WorkerBuild curl (in [Visual Studio Command 300*6236dae4SAndroid Build Coastguard Workerprompt](../winbuild/README.md#open-a-command-prompt)): 301*6236dae4SAndroid Build Coastguard Worker 302*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/curl/curl 303*6236dae4SAndroid Build Coastguard Worker % cd curl/winbuild 304*6236dae4SAndroid Build Coastguard Worker % nmake /f Makefile.vc mode=dll WITH_MSH3=dll MSH3_PATH="C:/Program Files/msh3" MACHINE=x64 305*6236dae4SAndroid Build Coastguard Worker 306*6236dae4SAndroid Build Coastguard Worker**Note** - If you encounter a build error with `tool_hugehelp.c` being 307*6236dae4SAndroid Build Coastguard Workermissing, rename `tool_hugehelp.c.cvs` in the same directory to 308*6236dae4SAndroid Build Coastguard Worker`tool_hugehelp.c` and then run `nmake` again. 309*6236dae4SAndroid Build Coastguard Worker 310*6236dae4SAndroid Build Coastguard WorkerRun in the `C:/Program Files/msh3/lib` directory, copy `curl.exe` to that 311*6236dae4SAndroid Build Coastguard Workerdirectory, or copy `msquic.dll` and `msh3.dll` from that directory to the 312*6236dae4SAndroid Build Coastguard Worker`curl.exe` directory. For example: 313*6236dae4SAndroid Build Coastguard Worker 314*6236dae4SAndroid Build Coastguard Worker % C:\Program Files\msh3\lib> F:\curl\builds\libcurl-vc-x64-release-dll-ipv6-sspi-schannel-msh3\bin\curl.exe --http3 https://curl.se/ 315*6236dae4SAndroid Build Coastguard Worker 316*6236dae4SAndroid Build Coastguard Worker# `--http3` 317*6236dae4SAndroid Build Coastguard Worker 318*6236dae4SAndroid Build Coastguard WorkerUse only HTTP/3: 319*6236dae4SAndroid Build Coastguard Worker 320*6236dae4SAndroid Build Coastguard Worker % curl --http3-only https://example.org:4433/ 321*6236dae4SAndroid Build Coastguard Worker 322*6236dae4SAndroid Build Coastguard WorkerUse HTTP/3 with fallback to HTTP/2 or HTTP/1.1 (see "HTTPS eyeballing" below): 323*6236dae4SAndroid Build Coastguard Worker 324*6236dae4SAndroid Build Coastguard Worker % curl --http3 https://example.org:4433/ 325*6236dae4SAndroid Build Coastguard Worker 326*6236dae4SAndroid Build Coastguard WorkerUpgrade via Alt-Svc: 327*6236dae4SAndroid Build Coastguard Worker 328*6236dae4SAndroid Build Coastguard Worker % curl --alt-svc altsvc.cache https://curl.se/ 329*6236dae4SAndroid Build Coastguard Worker 330*6236dae4SAndroid Build Coastguard WorkerSee this [list of public HTTP/3 servers](https://bagder.github.io/HTTP3-test/) 331*6236dae4SAndroid Build Coastguard Worker 332*6236dae4SAndroid Build Coastguard Worker### HTTPS eyeballing 333*6236dae4SAndroid Build Coastguard Worker 334*6236dae4SAndroid Build Coastguard WorkerWith option `--http3` curl attempts earlier HTTP versions as well should the 335*6236dae4SAndroid Build Coastguard Workerconnect attempt via HTTP/3 not succeed "fast enough". This strategy is similar 336*6236dae4SAndroid Build Coastguard Workerto IPv4/6 happy eyeballing where the alternate address family is used in 337*6236dae4SAndroid Build Coastguard Workerparallel after a short delay. 338*6236dae4SAndroid Build Coastguard Worker 339*6236dae4SAndroid Build Coastguard WorkerThe IPv4/6 eyeballing has a default of 200ms and you may override that via 340*6236dae4SAndroid Build Coastguard Worker`--happy-eyeballs-timeout-ms value`. Since HTTP/3 is still relatively new, we 341*6236dae4SAndroid Build Coastguard Workerdecided to use this timeout also for the HTTP eyeballing - with a slight 342*6236dae4SAndroid Build Coastguard Workertwist. 343*6236dae4SAndroid Build Coastguard Worker 344*6236dae4SAndroid Build Coastguard WorkerThe `happy-eyeballs-timeout-ms` value is the **hard** timeout, meaning after 345*6236dae4SAndroid Build Coastguard Workerthat time expired, a TLS connection is opened in addition to negotiate HTTP/2 346*6236dae4SAndroid Build Coastguard Workeror HTTP/1.1. At half of that value - currently - is the **soft** timeout. The 347*6236dae4SAndroid Build Coastguard Workersoft timeout fires, when there has been **no data at all** seen from the 348*6236dae4SAndroid Build Coastguard Workerserver on the HTTP/3 connection. 349*6236dae4SAndroid Build Coastguard Worker 350*6236dae4SAndroid Build Coastguard WorkerSo, without you specifying anything, the hard timeout is 200ms and the soft is 100ms: 351*6236dae4SAndroid Build Coastguard Worker 352*6236dae4SAndroid Build Coastguard Worker * Ideally, the whole QUIC handshake happens and curl has an HTTP/3 connection 353*6236dae4SAndroid Build Coastguard Worker in less than 100ms. 354*6236dae4SAndroid Build Coastguard Worker * When QUIC is not supported (or UDP does not work for this network path), no 355*6236dae4SAndroid Build Coastguard Worker reply is seen and the HTTP/2 TLS+TCP connection starts 100ms later. 356*6236dae4SAndroid Build Coastguard Worker * In the worst case, UDP replies start before 100ms, but drag on. This starts 357*6236dae4SAndroid Build Coastguard Worker the TLS+TCP connection after 200ms. 358*6236dae4SAndroid Build Coastguard Worker * When the QUIC handshake fails, the TLS+TCP connection is attempted right 359*6236dae4SAndroid Build Coastguard Worker away. For example, when the QUIC server presents the wrong certificate. 360*6236dae4SAndroid Build Coastguard Worker 361*6236dae4SAndroid Build Coastguard WorkerThe whole transfer only fails, when **both** QUIC and TLS+TCP fail to 362*6236dae4SAndroid Build Coastguard Workerhandshake or time out. 363*6236dae4SAndroid Build Coastguard Worker 364*6236dae4SAndroid Build Coastguard WorkerNote that all this happens in addition to IP version happy eyeballing. If the 365*6236dae4SAndroid Build Coastguard Workername resolution for the server gives more than one IP address, curl tries all 366*6236dae4SAndroid Build Coastguard Workerthose until one succeeds - just as with all other protocols. If those IP 367*6236dae4SAndroid Build Coastguard Workeraddresses contain both IPv6 and IPv4, those attempts happen, delayed, in 368*6236dae4SAndroid Build Coastguard Workerparallel (the actual eyeballing). 369*6236dae4SAndroid Build Coastguard Worker 370*6236dae4SAndroid Build Coastguard Worker## Known Bugs 371*6236dae4SAndroid Build Coastguard Worker 372*6236dae4SAndroid Build Coastguard WorkerCheck out the [list of known HTTP3 bugs](https://curl.se/docs/knownbugs.html#HTTP3). 373*6236dae4SAndroid Build Coastguard Worker 374*6236dae4SAndroid Build Coastguard Worker# HTTP/3 Test server 375*6236dae4SAndroid Build Coastguard Worker 376*6236dae4SAndroid Build Coastguard WorkerThis is not advice on how to run anything in production. This is for 377*6236dae4SAndroid Build Coastguard Workerdevelopment and experimenting. 378*6236dae4SAndroid Build Coastguard Worker 379*6236dae4SAndroid Build Coastguard Worker## Prerequisite(s) 380*6236dae4SAndroid Build Coastguard Worker 381*6236dae4SAndroid Build Coastguard WorkerAn existing local HTTP/1.1 server that hosts files. Preferably also a few huge 382*6236dae4SAndroid Build Coastguard Workerones. You can easily create huge local files like `truncate -s=8G 8GB` - they 383*6236dae4SAndroid Build Coastguard Workerare huge but do not occupy that much space on disk since they are just big 384*6236dae4SAndroid Build Coastguard Workerholes. 385*6236dae4SAndroid Build Coastguard Worker 386*6236dae4SAndroid Build Coastguard WorkerIn a Debian setup you can install apache2. It runs on port 80 and has a 387*6236dae4SAndroid Build Coastguard Workerdocument root in `/var/www/html`. Download the 8GB file from apache with `curl 388*6236dae4SAndroid Build Coastguard Workerlocalhost/8GB -o dev/null` 389*6236dae4SAndroid Build Coastguard Worker 390*6236dae4SAndroid Build Coastguard WorkerIn this description we setup and run an HTTP/3 reverse-proxy in front of the 391*6236dae4SAndroid Build Coastguard WorkerHTTP/1 server. 392*6236dae4SAndroid Build Coastguard Worker 393*6236dae4SAndroid Build Coastguard Worker## Setup 394*6236dae4SAndroid Build Coastguard Worker 395*6236dae4SAndroid Build Coastguard WorkerYou can select either or both of these server solutions. 396*6236dae4SAndroid Build Coastguard Worker 397*6236dae4SAndroid Build Coastguard Worker### nghttpx 398*6236dae4SAndroid Build Coastguard Worker 399*6236dae4SAndroid Build Coastguard WorkerGet, build and install quictls, nghttp3 and ngtcp2 as described 400*6236dae4SAndroid Build Coastguard Workerabove. 401*6236dae4SAndroid Build Coastguard Worker 402*6236dae4SAndroid Build Coastguard WorkerGet, build and install nghttp2: 403*6236dae4SAndroid Build Coastguard Worker 404*6236dae4SAndroid Build Coastguard Worker % git clone https://github.com/nghttp2/nghttp2.git 405*6236dae4SAndroid Build Coastguard Worker % cd nghttp2 406*6236dae4SAndroid Build Coastguard Worker % autoreconf -fi 407*6236dae4SAndroid Build Coastguard Worker % PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/daniel/build-quictls/lib/pkgconfig:/home/daniel/build-nghttp3/lib/pkgconfig:/home/daniel/build-ngtcp2/lib/pkgconfig LDFLAGS=-L/home/daniel/build-quictls/lib CFLAGS=-I/home/daniel/build-quictls/include ./configure --enable-maintainer-mode --prefix=/home/daniel/build-nghttp2 --disable-shared --enable-app --enable-http3 --without-jemalloc --without-libxml2 --without-systemd 408*6236dae4SAndroid Build Coastguard Worker % make && make install 409*6236dae4SAndroid Build Coastguard Worker 410*6236dae4SAndroid Build Coastguard WorkerRun the local h3 server on port 9443, make it proxy all traffic through to 411*6236dae4SAndroid Build Coastguard WorkerHTTP/1 on localhost port 80. For local toying, we can just use the test cert 412*6236dae4SAndroid Build Coastguard Workerthat exists in curl's test dir. 413*6236dae4SAndroid Build Coastguard Worker 414*6236dae4SAndroid Build Coastguard Worker % CERT=$CURLSRC/tests/stunnel.pem 415*6236dae4SAndroid Build Coastguard Worker % $HOME/bin/nghttpx $CERT $CERT --backend=localhost,80 \ 416*6236dae4SAndroid Build Coastguard Worker --frontend="localhost,9443;quic" 417*6236dae4SAndroid Build Coastguard Worker 418*6236dae4SAndroid Build Coastguard Worker### Caddy 419*6236dae4SAndroid Build Coastguard Worker 420*6236dae4SAndroid Build Coastguard Worker[Install Caddy](https://caddyserver.com/docs/install). For easiest use, the binary 421*6236dae4SAndroid Build Coastguard Workershould be either in your PATH or your current directory. 422*6236dae4SAndroid Build Coastguard Worker 423*6236dae4SAndroid Build Coastguard WorkerCreate a `Caddyfile` with the following content: 424*6236dae4SAndroid Build Coastguard Worker~~~ 425*6236dae4SAndroid Build Coastguard Workerlocalhost:7443 { 426*6236dae4SAndroid Build Coastguard Worker respond "Hello, world! you are using {http.request.proto}" 427*6236dae4SAndroid Build Coastguard Worker} 428*6236dae4SAndroid Build Coastguard Worker~~~ 429*6236dae4SAndroid Build Coastguard Worker 430*6236dae4SAndroid Build Coastguard WorkerThen run Caddy: 431*6236dae4SAndroid Build Coastguard Worker 432*6236dae4SAndroid Build Coastguard Worker % ./caddy start 433*6236dae4SAndroid Build Coastguard Worker 434*6236dae4SAndroid Build Coastguard WorkerMaking requests to `https://localhost:7443` should tell you which protocol is being used. 435*6236dae4SAndroid Build Coastguard Worker 436*6236dae4SAndroid Build Coastguard WorkerYou can change the hard-coded response to something more useful by replacing `respond` 437*6236dae4SAndroid Build Coastguard Workerwith `reverse_proxy` or `file_server`, for example: `reverse_proxy localhost:80` 438