#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

3 releases

0.0.2 Jan 17, 2025
0.0.1 Jan 10, 2025
0.0.0 Nov 21, 2023

#572 in Network programming

Download history 1/week @ 2024-12-09 124/week @ 2025-01-06 133/week @ 2025-01-13 70/week @ 2025-01-20

327 downloads per month

Apache-2.0

375KB
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

~67MB
~1.5M SLoC