#tls #rustls #default

rustls-connector

Connector similar to openssl or native-tls for rustls

46 releases

0.21.6 Mar 17, 2025
0.21.4 Aug 29, 2024
0.21.0 May 2, 2024
0.19.2 Dec 6, 2023
0.7.0 Jun 10, 2019

#269 in Network programming

Download history 32864/week @ 2024-12-05 33290/week @ 2024-12-12 17894/week @ 2024-12-19 9672/week @ 2024-12-26 22265/week @ 2025-01-02 32760/week @ 2025-01-09 32068/week @ 2025-01-16 32415/week @ 2025-01-23 37189/week @ 2025-01-30 40139/week @ 2025-02-06 32062/week @ 2025-02-13 35620/week @ 2025-02-20 32784/week @ 2025-02-27 35245/week @ 2025-03-06 35969/week @ 2025-03-13 29996/week @ 2025-03-20

140,213 downloads per month
Used in 22 crates (8 directly)

BSD-2-Clause

15KB
170 lines

rustls-connector

API Docs Build status Downloads

Connector similar to openssl or native-tls for rustls

rustls-connector is a library aiming at simplifying using rustls as an alternative to openssl and native-tls

Warning about crypto backends

A crypto implementation must be enabled in rustls using feature flags. We mimic what rustls does, providing one feature flag per implementation and enabling the same as rustls by default. Available options are:

  • rustls--aws_lc_rs (default)
  • rustls--ring

Examples

To connect to a remote server:

use rustls_connector::RustlsConnector;

use std::{
    io::{Read, Write},
    net::TcpStream,
};

let connector = RustlsConnector::new_with_native_certs().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));

Dependencies

~8–23MB
~503K SLoC