Crates.io | rustls-connector |
lib.rs | rustls-connector |
version | 0.21.4 |
source | src |
created_at | 2019-05-25 22:26:01.28473 |
updated_at | 2024-08-29 20:34:33.33121 |
description | Connector similar to openssl or native-tls for rustls |
homepage | |
repository | https://github.com/amqp-rs/rustls-connector |
max_upload_size | |
id | 137029 |
size | 16,252 |
rustls-connector is a library aiming at simplifying using rustls as an alternative to openssl and native-tls
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
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));