-
-
Notifications
You must be signed in to change notification settings - Fork 803
Description
I saw many use cases in issues that we want to have more control over rustls to integrate into async ecosystem.
Our certificates recevied from control panel, and we want to set different cert based on SNI and update at runtime.
All certifcates maintain in tokio::sync::RwLock, but rustls ResolvesServerCert and many other trait defined in ServerConfig are Sync, which can't embed into async workflow.
https://docs.rs/rustls/latest/rustls/server/trait.ResolvesServerCert.html
Could we support openssl https://www.openssl.org/docs/man1.1.1/man3/SSL_set_ex_data.html to empower rustls callback trait?
we can set extra certificate in async workflow and then call rustls handshake, so that we can satisfy many async use case
The api should change to
pub trait ResolvesServerCert: Send + Sync {
/// Choose a certificate chain and matching key given simplified
/// ClientHello information.
///
/// Return `None` to abort the handshake.
fn resolve(&self, ssl: &mut SslConnection, client_hello: ClientHello) -> Option<Arc<sign::CertifiedKey>> {
let cert = ssl.extra_data("certificate");
return Some(Arc::new(cert))
}
}
client_hello is useless for me, we have a tls client hello parse https://github.com/iamwwc/tunnel/blob/master/src/app/sniffer.rs#L91, which extract SNI from record, and then wrapper into other high level tls stream wrapper
https://github.com/iamwwc/tunnel/blob/af5ce758d74d092c9905d6c57957058f9998e61c/src/app/sniffer.rs#L186