warp_openssl/lib.rs
1#![doc(html_root_url = "https://docs.rs/warp-openssl")]
2#![deny(missing_docs)]
3#![deny(missing_debug_implementations)]
4#![cfg_attr(test, deny(warnings))]
5
6//! # warp-openssl
7//!
8//! warp-openssl adds an openssl compatibility layer to [warp](https://docs.rs/warp).
9//!
10//! By default warp ships with support for rustls as the TLS layer which makes warp
11//! unusable in some environments where only openssl is allowed.
12//!
13//! In order to use the openssl compatibility layer just import serve from warp_openssl
14//! instead of warp.
15//!
16//! So the following example:
17//! ```
18//! use warp::serve;
19//!
20//! let server = serve(warp::Filter::map(warp::any(), || "Hello, World!"));
21//! ```
22//!
23//! would convert to:
24//!
25//! ```
26//! use warp_openssl::serve;
27//!
28//! let cert = vec![]; // certificate to use
29//! let key = vec![]; // private key for the certificate
30//! let server = serve(warp::Filter::map(warp::any(), || "Hello, World!"))
31//! .key(key)
32//! .cert(cert);
33//! ```
34//!
35//! There is additional support for SSL key logging file to enable viewing network traffic in wireshark.
36//! Just set the SSLKEYLOGFILE environment variable to the path of the file you want to use
37//! and the key log gets generated to that file.
38//!
39//! The client certificate can be accessed in a filter by getting the extension:
40//!
41//! ```
42//! use warp_openssl::serve;
43//!
44//! let cert = vec![]; // certificate to use
45//! let key = vec![]; // private key for the certificate
46//! let server = serve(warp::Filter::map(
47//! warp::Filter::and(warp::any(), warp::filters::ext::optional()),
48//! |_cert: Option<warp_openssl::Certificate>| "Hello, World!"
49//! ))
50//! .key(key)
51//! .cert(cert);
52//! ```
53
54#[doc(hidden)]
55pub type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
56#[doc(hidden)]
57pub type Result<T> = std::result::Result<T, Error>;
58
59mod acceptor;
60mod certificate;
61mod config;
62mod server;
63mod stream;
64
65pub use certificate::{Certificate, CertificateVerifier};
66pub use server::{serve, OpensslServer};