DEV Community

Cover image for Installing curl with http3 on MacOS
Justin
Justin

Posted on

Installing curl with http3 on MacOS

When you are all said and done with this tutorial, you'll be able to double check http3 support via the curl command like this:

curl --http3 https://cloudflare-quic.com -I
HTTP/3 200
date: Fri, 24 Jul 2020 08:10:24 GMT
content-type: text/html
content-length: 106072
set-cookie: __cfduid=d8647a359d68a89c060bde4f373e18cc61595578224; expires=Sun, 23-Aug-20 08:10:24 GMT; path=/; domain=.cloudflare-quic.com; HttpOnly; SameSite=Lax; Secure
cf-request-id: 042178a64b0000188b7b1d9200000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 5b7c2a1d4eb5188b-MAN
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
Enter fullscreen mode Exit fullscreen mode

Unfortunately, this currently involves building curl from source, luckily for us, cloudflare makes this even easier.

# Clean up any old version of curl you may have already tried to install
brew remove -f curl

# Download the curl ruby install script provided by cloudflare
wget https://raw.githubusercontent.com/cloudflare/homebrew-cloudflare/master/curl.rb

# Install curl via that script from the latest git repos
brew install --HEAD -s curl.rb

# Tell your cli to use the curl version just installed (if you're using zsh, othwerise you might need `~/.bashrc`)
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc

# Reload your config
source ~/.zshrc

# Double check it's using the right curl
which curl # Should output "/usr/local/opt/curl/bin/curl"

# Double check http3
$ curl --version | grep HTTP3
  Features: alt-svc AsynchDNS brotli HTTP2 HTTP3 IDN IPv6 Largefile libz MultiSSL NTLM NTLM_WB SSL UnixSockets zstd

# Try curl on any HTTP/3 enabled sites.
curl --http3 https://blog.cloudflare.com -I
Enter fullscreen mode Exit fullscreen mode

Have fun upgrading all the servers!

Top comments (6)

Collapse
 
sprive profile image
Scott Prive

Is the CloudFlare curl project unmaintained?
The docs (curl HTTP 3 tutorial) have gone away:

There's Homebrew build issue Errno::ENOENT: No such file or directory - lib/mk-ca-bundle.pl covered by both:
github.com/cloudflare/homebrew-clo...
github.com/cloudflare/homebrew-clo...

You can use the alternate Git repo linked below, or you need only make 1 line changes to curl.rb, per:
github.com/cloudflare/homebrew-clo...

Collapse
 
gwynethllewelyn profile image
Gwyneth Llewelyn

Thanks! It seems as if Cloudflare has made this as simple as possible... unfortunately, though, at the time of writing, there are several issues which need to be fixed in order to run this.

First, the version of Ruby shipped with macOS 11.5 seems to be outdated/broken/missing essential functionality. But it's not a good idea to uninstall Ruby and replace it by something else, of course; so the suggested alternative is to set HOMEBREW_FORCE_VENDOR_RUBY=1 before running the above commands.

It should temporarily install a recent version of Ruby (3.X as opposed to 2.6.X shipping by default with macOS Big Sur) and do whatever it's supposed to do using that version of Ruby.

Unfortunately, my own Homebrew setup seems to be quite broken after way too many experiments, and, as a consequence, I cannot follow these instructions, but that's my fault β€” not yours (neither Cloudflare's β€” they're keeping everything up to date).

Collapse
 
khanakia profile image
Aman Bansal

Getting error
==> ./configure --prefix=/opt/homebrew/Cellar/curl/HEAD-c5d8895 --with-ssl=/private/tmp/curl-20221003-97661-1jujnek/quiche/quiche/deps/boringssl/src -
==> make install
==> make install -C scripts
Error: An exception occurred within a child process:
Errno::ENOENT: No such file or directory - lib/mk-ca-bundle.pl

Collapse
 
sinwoobang profile image
Sin-Woo Bang

You can use this one instead if on Mac OS Apple Silicon.

Collapse
 
ship_da_code profile image
Paul Bertain

Had to follow this page for one change (adding FFI):

github.com/ctsrc/homebrew-cloudfla...

Collapse
 
365cent profile image
365cent • Edited

Btw, if you don't have wget installed, use curl -O.