hyperium / hyperium.github.io

http://hyper.rs
29 stars 68 forks source link

TLS server support? #46

Open fluffysquirrels opened 4 years ago

fluffysquirrels commented 4 years ago

The guide doesn't mention TLS server support, which I would argue is an important feature for many users. I realise that third-party crates are required to support TLS with hyper, but how about linking to some of them or providing an example to make it a bit easier for new users to find? For comparison, TLS configuration is mentioned for the hyper client and there is a link to hyper-tls

Similar to how reqwest is mentioned in the hyper README.md as a high-level easy-to-use wrapper over the hyper client, is it intended for higher-level server frameworks like warp to be easy-to-use wrappers over the hyper server that provide TLS? In which case how about linking to some or even to the Web Development Frameworks page on arewewebyet.org

Would you accept a PR for this?

seanmonstar commented 4 years ago

Good point!

Perhaps the hyper-tls crate should provide a hyper::server::Accept implementation for easy usage, and then we can show how to easily use it to get up and running, and describe how one could pick a different TLS implementation if desired. What do you think of that?

fluffysquirrels commented 4 years ago

Seems like a good plan to me. I can work on an Accept implementation in hyper-tls and hyper-rustls.

fluffysquirrels commented 4 years ago

I wrote a server example for hyper-tls that uses hyper::server::accept::from_stream and is quite short: https://github.com/fluffysquirrels/hyper-tls/blob/server-example/examples/server.rs. Do you think it's worth extracting something from that into the hyper-tls lib, and if so what :) ? Perhaps a fn(TcpListener, tokio_tls::TlsAcceptor) -> impl hyper::server::accept::Accept?

hyper-rustls had a similar example already, which I worked from. I could write a PR to use hyper::server::accept::from_stream and trim down their example a bit. Thoughts?