3 releases
0.0.2 | Jan 17, 2025 |
---|---|
0.0.1 | Jan 10, 2025 |
0.0.0 | Nov 21, 2023 |
#572 in Network programming
327 downloads per month
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