<div align="center">
[](https://docs.rs/rustls-connector)
[](https://github.com/amqp-rs/rustls-connector/actions)
[](https://crates.io/crates/rustls-connector)
[](https://deps.rs/repo/github/amqp-rs/rustls-connector)
[](LICENSE)
**A TLS connector for rustls modelled after the `openssl` and `native-tls` APIs.**
</div>
Wraps `rustls` with a high-level `RustlsConnector` type that mirrors the
ergonomics of `native_tls::TlsConnector`, making it straightforward to swap
TLS backends in existing code. An async variant is available via the `futures`
feature.
## Feature flags
### Certificate store (pick at least one)
| `platform-verifier` *(default)* | Platform trust store via rustls-platform-verifier |
| `native-certs` | Native root certificates via rustls-native-certs |
| `webpki-root-certs` | Bundled Mozilla root certificate set |
### Rustls crypto provider (at least one required)
| `rustls--aws_lc_rs` *(default)* | Uses aws-lc-rs |
| `rustls--ring` | Uses ring (more portable, e.g. builds on Windows) |
### Miscellaneous
| `futures` | Async connect via `futures-rustls` |
| `logging` | Enable rustls TLS logging |
## Example
To connect to a remote server:
```rust
use rustls_connector::RustlsConnector;
use std::{
io::{Read, Write},
net::TcpStream,
};
let connector = RustlsConnector::new_with_platform_verifier().unwrap();
let stream = TcpStream::connect("google.com:443").unwrap();
let mut stream = connector.connect("google.com", stream).unwrap();
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
let mut res = vec![];
stream.read_to_end(&mut res).unwrap();
println!("{}", String::from_utf8_lossy(&res));
```