Apache Thrift TLS with mutual authentication

This package aims to provide full TLS (1.2 and 1.3) support to Apache Thrift for Rust. It provides such support by being as unobtrusive as possible and with very little overhead in terms of additional code needed.

TLS support is provided via Rustls, a modern, fast and powerfull TLS library written in Rust.

Note:

Technical note

How do I use this?

Client and server demo

There is a client-server example in the Github repo: https://github.com/dguerri/rust-thrift-tls. You will find a client-server example under thrift-tls-example using TLS mutual authentication.

  1. Run setup.sh to create X509 certs and related keys and to create the Thift spec file
  2. Run the server: cargo run --bin server
  3. Run the client: cargo run --bin client

Use RUST_LOG=debug to see debug messages

Code example

Client (no client auth)

```rust let mut c = TLSTTcpChannel::new(); // create a new TLS session with default (embedded) RootCertStore c.open( "localhost:9000", None, // Do not perform client auth None, // Default (embedded) RootCertStore )?;

// build the input/output protocol as usual (see "plain" Thrift examples)
// [...]

```

Server example

```rust // build transport factories and protocols as usual (see "plain" Thrift examples) // [...]

// create a pre-threaded server
let mut server = TLSTServer::new(
    i_tran_fact,
    i_prot_fact,
    o_tran_fact,
    o_prot_fact,
    processor,
    10,
    X509Credentials::new("x509/server.crt", "x509/server.key"),
    None,   // Default (embedded) RootCertStore
    false,  // Client authentication not required
    None,   // No connection hook
);

// set listen address
let listen_address = "127.0.0.1:9000";
log::info!("binding to {}", listen_address);
server.listen(&listen_address)

```