heres what i tried
use std::{io::Write, net::TcpStream};
use std::sync::Arc;
use rustls::{ClientConnection, RootCertStore, Stream};
fn main() {
let mut client = Client::new();
client.stream.write_all(b"hello");
}
impl<'a> Client<'a> {
fn new() -> Self {
let root_store = RootCertStore {
roots: webpki_roots::TLS_SERVER_ROOTS.into(),
};
let mut config = rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth();
// Allow using SSLKEYLOGFILE.
config.key_log = Arc::new(rustls::KeyLogFile::new());
let server_name = "www.rust-lang.org".try_into().unwrap();
let mut conn = rustls::ClientConnection::new(Arc::new(config), server_name).unwrap();
let mut sock = TcpStream::connect("www.rust-lang.org:443").unwrap();
let mut tls = rustls::Stream::new(&mut conn, &mut sock);
Client { stream: &mut tls}
}
}
struct Client<'a> {
stream: &'a mut Stream<'a, ClientConnection, TcpStream>,
}