#s2n-tls #hyper #hyper-http #allowing #hyper-client #builder #client-builder

s2n-tls-hyper

A compatbility crate allowing s2n-tls to be used with the hyper HTTP library

5 releases

new 0.0.4 Feb 19, 2025
0.0.3 Feb 8, 2025
0.0.2 Jan 17, 2025
0.0.1 Jan 10, 2025
0.0.0 Nov 21, 2023

#525 in Network programming

Download history 1/week @ 2024-12-10 132/week @ 2025-01-07 137/week @ 2025-01-14 59/week @ 2025-01-21 129/week @ 2025-02-04 54/week @ 2025-02-11

254 downloads per month

Apache-2.0

390KB
7K SLoC

s2n-tls-hyper provides compatibility structs for hyper, allowing s2n-tls to be used as the underlying TLS implementation with hyper clients.

This crate is currently being developed and is unstable.


lib.rs:

This crate provides compatibility structs for the hyper HTTP library, allowing s2n-tls to be used as the underlying TLS implementation to negotiate HTTPS with hyper clients.

s2n-tls-hyper provides an HttpsConnector struct which is compatible with the hyper_util::client::legacy::Client builder, allowing hyper clients to be constructed with configurable s2n-tls connections. The following example demonstrates how to construct a hyper client with s2n-tls:

use std::str::FromStr;
use hyper_util::{
    client::legacy::Client,
    rt::TokioExecutor,
};
use s2n_tls_hyper::connector::HttpsConnector;
use s2n_tls::config::Config;
use bytes::Bytes;
use http_body_util::Empty;
use http::uri::Uri;

// An `HttpsConnector` is built with an `s2n_tls::connection::Builder`, such as an
// `s2n_tls::config::Config`, which allows for the underlying TLS connection to be configured.
let config = Config::default();

// The `HttpsConnector` wraps hyper's `HttpConnector`. `HttpsConnector::new()` will create
// a new `HttpConnector` to wrap.
let connector = HttpsConnector::new(Config::default());

// The `HttpsConnector` can then be provided to the hyper Client builder, which can be used to
// send HTTP requests over HTTPS by specifying the HTTPS scheme in the URL.
let client: Client<_, Empty<Bytes>> =
    Client::builder(TokioExecutor::new()).build(connector);

Dependencies

~68MB
~1.5M SLoC