1use std::{
2 io::{Read as _, Write as _},
3 net::TcpStream,
4};
5
6use apple_security_framework::secure_transport::ClientBuilder;
7
8fn main() {
9 let stream = TcpStream::connect("example.com:443").unwrap();
10 let mut stream = ClientBuilder::new()
11 .handshake("example.com", stream)
12 .unwrap();
13 println!(
14 "negotiated cipher: {:?}",
15 stream.context().negotiated_cipher().unwrap()
16 );
17 println!(
18 "negotiated version: {:?}",
19 stream.context().negotiated_protocol_version().unwrap()
20 );
21
22 stream
23 .write_all(b"GET / HTTP/1.1\r\nhost: example.com\r\nconnection: close\r\n\r\n")
24 .unwrap();
25 stream.flush().unwrap();
26
27 let mut buf = vec![];
28 stream.read_to_end(&mut buf).unwrap();
29 println!("{}", String::from_utf8_lossy(&buf));
30}