programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
177 stars 63 forks source link

What is the best way to use different configs based on the connection ? #57

Closed dvtkrlbs closed 1 year ago

dvtkrlbs commented 1 year ago

My use case is I need to use different server configs based on the SNI value (multiple domains each with different certificates and client certificate authentication requirements). Rustls offers an acceptor for this use case. I can see that there is an Accept trait for similiar use case. However looking at the code the default RustlsAcceptor uses a RustlsAcceptorFuture which actually setups the rustls. Should I make my own Acceptor if so do I need to replicate the behaviour of RustlsAcceptorFuture ?

programatik29 commented 1 year ago

Take a look at RustlsConfig::from_config it might just work for you.

If you want to implement Accept trait I suggest using BoxFuture as Future return type. Then you can return a normal async block like Box::pin(async move {}).