SlideShare a Scribd company logo
1 of 41
Download to read offline
@bagder
curl with rust
Daniel Stenberg – January 27, 2022
Daniel Stenberg
@bagder
https://daniel.haxx.se
Daniel Stenberg
@bagder
@bagder
Agenda
curl is C
Stable API and ABI
Backends
Making an HTTP backend
… and other backends
Challenges
Current status
Future
@bagder
@bagder
Q&A
Immediately
following
@bagder
@bagder
curl is C
@bagder
@bagder
When curl started there
was no choice
C89
Only now alternatives
appear for libraries
C keeps curl extremely
portable
C code will remain a build
option
@bagder
@bagder
Stable API and ABI
@bagder
@bagder
Reliable and predictable
libcurl is forwards API compatible
libcurl does not break the ABI – ever
libcurl exists everywhere
Compiled code from 2001 still works
The armored front we can’t tamper with
@bagder
10,000,000,000
installations
@bagder
Vulnerabilities
50% of past curl vulnerabilities are “C mistakes”
Memory-safe languages could help
Also doing other things to reduce risk
The future is more Internet-connected devices
@bagder
@bagder
Backends and third parties
@bagder
@bagder
Backends
(Build-time) selectable alternative
implementations
@bagder
@bagder
Backends
Backends are selectable and deselectable
Often platform dependent
Often use 3rd
party libraries
… which can differ in features, licensing and maturity
Can be done in other programming languages
The internal APIs are never exposed externally
@bagder
third party world map February 2022
I/O layer
URL parser libidn2
winidn
HTTP
TLS
OpenSSL
gskit
mbedTLS
wolfSSL
Schannel
Secure
Transport
GnuTLS
NSS
boringssl
libressl
AmiSSL
SFTP SCP LDAP
WinLDAP
OpenLDAP
RTMP
librtmp
Name resolver c-ares
compression
libz brotli
cookies
libpsl
IMAP SMTP POP3
HTTP/2
nghttp2
authentication
winsspi Heimdal
MIT
kerberos
HTTP/3
quiche
ngtcp2
HTTP/1
SSH
wolfSSH
libssh2
libssh
@bagder
BearSSL
nghttp3
zstd
FTP
Hyper
FTPS IMAPS POP3S SMBS SMTPS
GOPHERS HTTPS LDAPS RTMPS
libgsasl
rustls
@bagder
Many different backends
IDN
Name resolving
TLS
SSH
HTTP/3
HTTP content encoding
HTTP
@bagder
@bagder
The making of an HTTP backend
libcurl API
Generic transfer engine
HTTP
Creating and reusing connections
@bagder
HTTP involves a lot of things
Authentication
Creating a set of headers
Proxy specifics
Parsing content headers
Parsing transfer headers
HTTP/1 and HTTP/2 transmission
@bagder
Hyper is transmission-focused
Authentication
Creating a set of headers
Proxy specifics
Parsing content headers
Parsing transfer headers
HTTP/1 and HTTP/2 transmission
@bagder
Splitting up HTTP
Authentication
Creating a set of headers
Proxy specifics
Parsing content headers
Parsing transfer headers
HTTP/1 and HTTP/2 transmission
Parsing transfer headers
HTTP/1 and HTTP/2 transmission
Hyper Built-in + nghttp2
@bagder
build curl with hyper
$ ./configure --with-hyper=...
https://github.com/curl/curl/blob/master/docs/HYPER.md
@bagder
HTTP backends
libcurl API
Generic transfer engine
High-level HTTP
Creating and reusing connections
built-in
HTTP/1
nghttp2
HTTP/2
Hyper
HTTP/1 + 2
@bagder
libcurl backends application
HTTP
API
libcurl
Public API
Hyper
built-in
nghttp2
@bagder
rustls
@bagder
@bagder
rustls provides a C API in rustls-ffi
curl builds with different TLS libraries
build curl to use rustls-ffi
… profit!
another TLS backend
@bagder
quiche
@bagder
@bagder
quiche provides a C API
curl builds with different QUIC libraries
build curl to use quiche
… profit!
another HTTP/3 and QUIC backend
@bagder
libcurl backends
libidn2
winidn
Hyper
built-in
threaded
c-ares
sync
quiche
ngtcp2 +
nghttp3
libssh2
wolfSSH
libssh
BearSSL
Gskit
GnuTLS
mbedSSL NSS
OpenSSL Schannel
wolfSSL
Secure Transport
rustls
application
HTTP
API
TLS
API
IDN API
SSH API
HTTP/3
API
Resolver
API
Public API
libcurl
Content encoding
API
brotli
zstd
zlib
= just one
= one or more
nghttp2
@bagder
libcurl backends
libidn2
winidn
Hyper
built-in
threaded
c-ares
sync
quiche
ngtcp2 +
nghttp3
libssh2
wolfSSH
libssh
BearSSL
Gskit
GnuTLS
mbedSSL NSS
OpenSSL Schannel
wolfSSL
Secure Transport
rustls
application
HTTP
API
TLS
API
IDN API
SSH API
HTTP/3
API
Resolver
API
Public API
libcurl
Content encoding
API
brotli
zstd
zlib
= just one
= one or more
nghttp2
@bagder
Challenges
@bagder
@bagder
Using hyper
First user of the Hyper C API
Headers-only, no C docs yet
Splitting HTTP for built-in + Hyper took thinking
Keeping behavior with different API paradigms
Memory leaks are tricky to hunt down
Rust use is mostly seamless (and not the first use)
@bagder
@bagder
Using rustls
Early user of rustls-ffi
Headers-only, no C docs yet
Mostly done by others so easier for me!
The TLS backend situation was already mature
Not yet feature-complete
@bagder
@bagder
Using quiche
Early user of quiche
Headers-only, no C docs yet
Messy TLS situation (for QUIC)
Not yet feature-complete
@bagder
@bagder
Using rust
Updating rust and cargo “all the time”
Suitable for replacing one-component-at-a-time
I am a total rust rookie
@bagder
@bagder
Current status
@bagder
@bagder
Status
Using curl and Hyper from main dev branches
“experimental” and opt-in
HTTP/1 and HTTP/2
HTTP and HTTPS (TLS backend agnostic)
HTTP(S) proxies
Identical HTTP requests over the wire
98% test case success rate (~800 test cases)
@bagder
@bagder
Status now
hyper
“experimental” and opt-in
HTTP/1 and HTTP/2
HTTP and HTTPS (TLS backend agnostic)
HTTP(S) proxies
Identical HTTP requests over the wire
98% test case success rate (~800 test cases)
@bagder
rustls
“experimental” and opt-in
12 test cases disabled
no IP-addresses in cert?
quiche
“experimental” and opt-in
no HTTP/3 tests yet
QUIC and HTTP/3 are not “there” yet anyway
rust in curl
works perfectly well
depends entirely on the C APIs
… which are under-documented still
no stable OOM == panic (will abort)
You can
help!
@bagder
Future
@bagder
@bagder
Coming up
Make all test cases succeed
Verify libcurl API corner cases
Encourage users and developers to use rust backends
Provide binary builds
Enable by default?
More rust components?
More backend flavors?
@bagder
more curl!
Commercial curl support!
@bagder
Daniel Stenberg
@bagder
https://daniel.haxx.se/
Thank you!
Questions?

More Related Content

What's hot

High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
ScyllaDB
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF Abyss
Sasha Goldshtein
 

What's hot (20)

Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 
[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?[Container Plumbing Days 2023] Why was nerdctl made?
[Container Plumbing Days 2023] Why was nerdctl made?
 
OpenJDK Concurrent Collectors
OpenJDK Concurrent CollectorsOpenJDK Concurrent Collectors
OpenJDK Concurrent Collectors
 
How to Survive an OpenStack Cloud Meltdown with Ceph
How to Survive an OpenStack Cloud Meltdown with CephHow to Survive an OpenStack Cloud Meltdown with Ceph
How to Survive an OpenStack Cloud Meltdown with Ceph
 
Let's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg MeetupLet's talk about Failures with Kubernetes - Hamburg Meetup
Let's talk about Failures with Kubernetes - Hamburg Meetup
 
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
[OpenInfra Days Korea 2018] Day 2 - E5: GPU on Kubernetes
 
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et  ...
Livraison en continue avec l'outillage devops - Jenkins, Ansible, Docker et ...
 
Vulgarisation de la technologie de containers Docker
Vulgarisation de la technologie de containers DockerVulgarisation de la technologie de containers Docker
Vulgarisation de la technologie de containers Docker
 
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
Dynamic SSL Certificates and Other New Features in NGINX Plus R18 and NGINX O...
 
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
Diving Through The Layers: Investigating runc, containerd, and the Docker eng...
 
Cilium - Network security for microservices
Cilium - Network security for microservicesCilium - Network security for microservices
Cilium - Network security for microservices
 
CKA_1st.pptx
CKA_1st.pptxCKA_1st.pptx
CKA_1st.pptx
 
Docker containers
Docker containersDocker containers
Docker containers
 
簡介 Linux 的 Network Namespace 功能
簡介 Linux 的 Network Namespace 功能簡介 Linux 的 Network Namespace 功能
簡介 Linux 的 Network Namespace 功能
 
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
Canadian CNCF: "Emissary-ingress 101: An introduction to the CNCF incubation-...
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...
Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...
Velero & Beyond: Backup & Restore for Kubernetes Applications (Cloud Native S...
 
Staring into the eBPF Abyss
Staring into the eBPF AbyssStaring into the eBPF Abyss
Staring into the eBPF Abyss
 
What is new in BIND 9.11?
What is new in BIND 9.11?What is new in BIND 9.11?
What is new in BIND 9.11?
 
Ceph - A distributed storage system
Ceph - A distributed storage systemCeph - A distributed storage system
Ceph - A distributed storage system
 

Similar to Curl with rust

Legacy of Void*
Legacy of Void*Legacy of Void*
Legacy of Void*
Adam Crain
 

Similar to Curl with rust (20)

HTTP/3 in curl - curl up 2022
HTTP/3 in curl - curl up 2022HTTP/3 in curl - curl up 2022
HTTP/3 in curl - curl up 2022
 
curl roadmap 2020
curl roadmap 2020curl roadmap 2020
curl roadmap 2020
 
mastering the curl command line.pdf
mastering the curl command line.pdfmastering the curl command line.pdf
mastering the curl command line.pdf
 
HTTP/3 is next generation HTTP
HTTP/3 is next generation HTTPHTTP/3 is next generation HTTP
HTTP/3 is next generation HTTP
 
mastering libcurl part 1
mastering libcurl part 1mastering libcurl part 1
mastering libcurl part 1
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!
 
HTTP/3 in curl 2020
HTTP/3 in curl 2020HTTP/3 in curl 2020
HTTP/3 in curl 2020
 
HTTP/3 in curl
HTTP/3 in curlHTTP/3 in curl
HTTP/3 in curl
 
Legacy of Void*
Legacy of Void*Legacy of Void*
Legacy of Void*
 
Build DynamoDB-Compatible Apps with Python
Build DynamoDB-Compatible Apps with PythonBuild DynamoDB-Compatible Apps with Python
Build DynamoDB-Compatible Apps with Python
 
Kernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVSKernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVS
 
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
 
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022
 
Docker cloud hybridation & orchestration
Docker cloud hybridation & orchestrationDocker cloud hybridation & orchestration
Docker cloud hybridation & orchestration
 
Scientific Computing @ Fred Hutch
Scientific Computing @ Fred HutchScientific Computing @ Fred Hutch
Scientific Computing @ Fred Hutch
 
HTTP/3 for everyone
HTTP/3 for everyoneHTTP/3 for everyone
HTTP/3 for everyone
 
Breaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CIBreaking Bad Habits with GitLab CI
Breaking Bad Habits with GitLab CI
 
Scale out, with Kubernetes (k8s)
Scale out, with Kubernetes (k8s)Scale out, with Kubernetes (k8s)
Scale out, with Kubernetes (k8s)
 
REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!REST in Peace. Long live gRPC!
REST in Peace. Long live gRPC!
 
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
Communication Amongst Microservices: Kubernetes, Istio, and Spring Cloud with...
 

More from Daniel Stenberg

More from Daniel Stenberg (20)

mastering libcurl part 2
mastering libcurl part 2mastering libcurl part 2
mastering libcurl part 2
 
curl - openfourm europe.pdf
curl - openfourm europe.pdfcurl - openfourm europe.pdf
curl - openfourm europe.pdf
 
curl experiments - curl up 2022
curl experiments - curl up 2022curl experiments - curl up 2022
curl experiments - curl up 2022
 
curl security - curl up 2022
curl security - curl up 2022curl security - curl up 2022
curl security - curl up 2022
 
The state of curl 2022
The state of curl 2022The state of curl 2022
The state of curl 2022
 
Let me tell you about curl
Let me tell you about curlLet me tell you about curl
Let me tell you about curl
 
Getting started with libcurl
Getting started with libcurlGetting started with libcurl
Getting started with libcurl
 
Landing code in curl
Landing code in curlLanding code in curl
Landing code in curl
 
Testing curl for security
Testing curl for securityTesting curl for security
Testing curl for security
 
common mistakes when using libcurl
common mistakes when using libcurlcommon mistakes when using libcurl
common mistakes when using libcurl
 
The state of curl 2020
The state of curl 2020The state of curl 2020
The state of curl 2020
 
curl better
curl bettercurl better
curl better
 
HTTP/3, QUIC and streaming
HTTP/3, QUIC and streamingHTTP/3, QUIC and streaming
HTTP/3, QUIC and streaming
 
HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!HTTP/3 over QUIC. All is new but still the same!
HTTP/3 over QUIC. All is new but still the same!
 
Just curl it!
Just curl it!Just curl it!
Just curl it!
 
curl - a hobby project that conquered the world
curl - a hobby project that conquered the worldcurl - a hobby project that conquered the world
curl - a hobby project that conquered the world
 
Http3 fullstackfest-2019
Http3 fullstackfest-2019Http3 fullstackfest-2019
Http3 fullstackfest-2019
 
Writing safe and secure code
Writing safe and secure codeWriting safe and secure code
Writing safe and secure code
 
The state of curl 2019
The state of curl 2019The state of curl 2019
The state of curl 2019
 
DNS over HTTPS
DNS over HTTPSDNS over HTTPS
DNS over HTTPS
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Curl with rust