roa-tls

Crates.ioroa-tls
lib.rsroa-tls
version0.5.0-rc
sourcesrc
created_at2020-03-03 15:19:35.642492
updated_at2020-03-20 13:51:31.094276
descriptiontls based acceptor for roa
homepagehttps://github.com/Hexilee/roa/wiki
repositoryhttps://github.com/Hexilee/roa
max_upload_size
id214947
size18,336
xixi (Hexilee)

documentation

https://docs.rs/roa-tls

README

Stable Test codecov Rust Docs Crate version Download Version License: MIT

Roa-tls

This crate provides an acceptor implementing roa_core::Accept and an app extension.

TlsIncoming

use roa_core::App;
use roa_tls::TlsIncoming;
use roa_tls::rustls::{ServerConfig, NoClientAuth};
use roa_tls::rustls::internal::pemfile::{certs, rsa_private_keys};
use std::fs::File;
use std::io::BufReader;

# fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut config = ServerConfig::new(NoClientAuth::new());
let mut cert_file = BufReader::new(File::open("../assets/cert.pem")?);
let mut key_file = BufReader::new(File::open("../assets/key.pem")?);
let cert_chain = certs(&mut cert_file).unwrap();
let mut keys = rsa_private_keys(&mut key_file).unwrap();
config.set_single_cert(cert_chain, keys.remove(0))?;

let incoming = TlsIncoming::bind("127.0.0.1:0", config)?;
let server = App::new(()).accept(incoming);
// server.await
Ok(())
# }

TlsListener

use roa_core::App;
use roa_tls::TlsListener;
use roa_tls::rustls::{ServerConfig, NoClientAuth};
use roa_tls::rustls::internal::pemfile::{certs, rsa_private_keys};
use std::fs::File;
use std::io::BufReader;

# fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut config = ServerConfig::new(NoClientAuth::new());
let mut cert_file = BufReader::new(File::open("../assets/cert.pem")?);
let mut key_file = BufReader::new(File::open("../assets/key.pem")?);
let cert_chain = certs(&mut cert_file).unwrap();
let mut keys = rsa_private_keys(&mut key_file).unwrap();
config.set_single_cert(cert_chain, keys.remove(0))?;

let (addr, server) = App::new(()).listen_tls_on("127.0.0.1:0", config)?;
// server.await
Ok(())
# }
Commit count: 722

cargo fmt