#tls-connector #rustls #native-tls #openssl

rustls-connector

Connector similar to openssl or native-tls for rustls

44 releases

0.21.4 Aug 29, 2024
0.21.0 May 2, 2024
0.20.1 Aug 19, 2024
0.19.2 Dec 6, 2023
0.7.0 Jun 10, 2019

#139 in Network programming

Download history 30625/week @ 2024-08-22 29796/week @ 2024-08-29 36292/week @ 2024-09-05 32383/week @ 2024-09-12 30897/week @ 2024-09-19 33566/week @ 2024-09-26 30925/week @ 2024-10-03 31809/week @ 2024-10-10 33719/week @ 2024-10-17 31868/week @ 2024-10-24 28609/week @ 2024-10-31 31090/week @ 2024-11-07 33257/week @ 2024-11-14 31916/week @ 2024-11-21 28960/week @ 2024-11-28 26221/week @ 2024-12-05

127,080 downloads per month
Used in 23 crates (9 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

~7–22MB
~494K SLoC