diff --git a/Cargo.toml b/Cargo.toml index 7d75412..133dad7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] +native-tls = "0.2" diff --git a/examples/native-tls.rs b/examples/native-tls.rs new file mode 100644 index 0000000..32acc40 --- /dev/null +++ b/examples/native-tls.rs @@ -0,0 +1,15 @@ +use native_tls::TlsConnector; +use std::io::{Read, Write}; +use std::net::TcpStream; + +fn main() { + let connector = TlsConnector::new().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)); +}