Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manuels/libtls.rs
Rust bindings for libressl's libtls
https://github.com/manuels/libtls.rs
Last synced: about 1 month ago
JSON representation
Rust bindings for libressl's libtls
- Host: GitHub
- URL: https://github.com/manuels/libtls.rs
- Owner: manuels
- Created: 2015-01-04T15:01:46.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-04T15:04:52.000Z (almost 10 years ago)
- Last Synced: 2024-11-16T04:46:10.630Z (about 2 months ago)
- Language: Rust
- Size: 125 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
Awesome Lists containing this project
README
tls::tls_init();
let cfg = tls::TLSConfig::new().unwrap();
cfg.set_key_file("./server.key").unwrap();
cfg.set_cert_file("./server.crt").unwrap();let server = tls::TLS::server().unwrap();
server.configure(&cfg).unwrap();let mut listener = std::io::TcpListener::bind("127.0.0.1:4433").unwrap()
.listen().unwrap();std::thread::Thread::spawn(move || {
let cfg = tls::TLSConfig::new().unwrap();
cfg.insecure_noverifycert();
cfg.insecure_noverifyhost();let mut client = tls::TLS::client().unwrap();
client.configure(&cfg).unwrap();client.connect("127.0.0.1", "4433").unwrap();
client.write(b"hello from client").unwrap();
let buf:Vec = client.read_exact(17).unwrap();
assert_eq!(buf, b"hello from server".to_vec());
}).detach();let stream = listener.accept().unwrap();
let mut conn = server.accept_socket(stream.as_raw_fd()).unwrap();conn.write(b"hello from server").unwrap();
let buf = conn.read_exact(17).unwrap();
assert_eq!(buf, b"hello from client".to_vec());conn.close().unwrap();