98 releases

0.3.36 Apr 2, 2026
0.3.35 Mar 2, 2026
0.3.34 Jan 16, 2026
0.3.32 Dec 11, 2025
0.0.1 Apr 21, 2021

#2020 in Cryptography

Download history 137251/week @ 2026-01-24 138837/week @ 2026-01-31 134091/week @ 2026-02-07 131906/week @ 2026-02-14 132760/week @ 2026-02-21 137067/week @ 2026-02-28 136172/week @ 2026-03-07 148683/week @ 2026-03-14 138270/week @ 2026-03-21 131253/week @ 2026-03-28 130805/week @ 2026-04-04 137113/week @ 2026-04-11 134595/week @ 2026-04-18 132570/week @ 2026-04-25 133629/week @ 2026-05-02 138121/week @ 2026-05-09

559,292 downloads per month
Used in 26 crates (7 directly)

Apache-2.0

2.5MB
38K SLoC

C 33K SLoC // 0.2% comments Rust 4.5K SLoC // 0.0% comments

This crate provides low level rust bindings for s2n-tls which are autogenerated with bindgen

This crate is not intended for direct consumption by end consumers. Interested developers should instead look at the s2n-tls or s2n-tls-tokio crates. These provide higher-level, more ergonomic bindings than the s2n-tls-sys crate.

The s2n-tls-sys bindings crate contains the raw C code of s2n-tls. By default, it follows this build process:

  1. Use the system C compiler to build libs2n.a
  2. Link the built libs2n.a to the Rust bindings
  3. Link against aws-lc through the aws-lc-rs crate

Bring your own libs2n with s2n-tls-sys crate

You can customize above build process to use your own pre-built libs2n. This is useful if you want the bindings to be built with a non-default libcrypto. Currently, the default libcrypto when generating rust bindings is aws-lc. Here's how you can do that:

  1. Clone s2n-tls and compile your preferred configuration of s2n-tls.

You may choose to link against a specific libcrypto at this step. For more information, see Building with a specific libcrypto. Also see Building s2n-tls for further guidance on configuring s2n-tls for your own use case.

  1. cd into your rust project and set environment variables to your libs2n artifacts.

This tells the bindings to link to pre-built libs2n when running the build script for s2n-tls-sys

export S2N_TLS_LIB_DIR=<PATH_TO_ROOT_OF_S2N_TLS>/build/lib
export S2N_TLS_INCLUDE_DIR=<PATH_TO_ROOT_OF_S2N_TLS>/api
export LD_LIBRARY_PATH=$S2N_TLS_LIB_DIR:$LD_LIBRARY_PATH

S2N_TLS_LIB_DIR points to the folder containing libs2n.a/libs2n.so artifact that you would like s2n-tls-sys to link against. S2N_TLS_INCLUDE_DIR points to the folder containing header files for libs2n.a/libs2n.so artifact. LD_LIBRARY_PATH adds the path to libs2n.a/libs2n.so artifact for dynamic linker's search path.

  1. Build your project. This triggers the build script for s2n-tls-sys
cargo build

Dependencies

~66MB
~2M SLoC