Crates.io | roa-tls |
lib.rs | roa-tls |
version | 0.5.0-rc |
source | src |
created_at | 2020-03-03 15:19:35.642492 |
updated_at | 2020-03-20 13:51:31.094276 |
description | tls based acceptor for roa |
homepage | https://github.com/Hexilee/roa/wiki |
repository | https://github.com/Hexilee/roa |
max_upload_size | |
id | 214947 |
size | 18,336 |
This crate provides an acceptor implementing roa_core::Accept
and an app extension.
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(())
# }
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(())
# }