fn main() {
let mut lp = Core::new().unwrap();
let loop1 = serve_https(lp.handle(), "cert1.pfx", 8443);
let loop2 = serve_https(lp.handle(), "cert2.pfx", 8444);
lp.run(loop1.join(loop2) ... ).unwrap();
}
fn serve_https(handle: Handle, cert: &str, port: usize) -> Box<Future<Item=(), Error=io::Error>> {
...
let listener = TcpListener::bind(&addr, &handle).unwrap();
let acceptor = TlsAcceptor::builder(pfx).unwrap().build().unwrap();
...
Box::new(listener.incoming().for_each(move |(socket, _)| {
acceptor.accept_async(socket).then(move |r| match r {
...
}
}
}
$ curl -k https://localhost:8444
{"success": true}
$ curl -k https://localhost:8443
TLS connection failed: Error { code: -50, message: "One or more parameters passed to a function were not valid." }
curl: (35) Server aborted the SSL handshake