-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access rustls::Session from hyper::Service #2463
Comments
If it's connection related data, you could collect that and make it part of your For example: // probably in a while loop?
let socket = listener.accept().await?;
// probably spawn the TLS handshake into a new task to not block the accept loop?
let tls = rustls_accept(socket, config).await?;
let session = tls.session().clone();
let svc = MyAppSvc { session };
hyper::server::conn::Http::new().serve_connection(tls, svc).await? |
Is it possible to do a similar thing on the client side? IIUC there is an But the problem is that there is no way to use this session afterwards with |
You can make a wrapper around the HttpsConnector that adds whatever data you need via the |
The question is more about how to extract a |
If I understand correctly, the only way to access let mut https_connector = hyper_rustls::HttpsConnector::from((http_connector, tls_config));
let mut https_stream = https_connector.call(dst).await.unwrap();
let keying_material = match https_stream {
MaybeHttpsStream::Https(ref mut tls_stream) => {
let (tcp_stream, session) = tls_stream.get_mut();
KeyingMaterial::export(session).expect("Couldn't generate keying material") But the problem is that I cannot use this In order to force impl<T> Service<Uri> for CustomConnector<T>
...
fn call(&mut self, dst: Uri) -> Self::Future {
let http_connector = self.http_connector.clone();
let tls_config = self.tls_config.clone();
let result = async move {
let mut https_connector = hyper_rustls::HttpsConnector::from((http_connector, tls_config));
let mut https_stream = https_connector.call(dst).await.unwrap();
match https_stream {
MaybeHttpsStream::Https(ref mut tls_stream) => {
let keying_material = {
let (tcp_stream, session) = tls_stream.get_mut();
KeyingMaterial::export(session).expect("Couldn't generate keying material")
};
// Send keying material in a separate HTTP request.
...
}
}
Ok(https_stream)
};
Box::pin(result)
} But the problem is similar: once I get |
Currently the parameters of
hyper::Service::call
only include aRequest
. And I'm curious if it's possible to access TCP/TLS connection internals somewhere from theService
. For example accessrustls::Session
.Accessing TLS session could be useful for multiple reasons, for example for implementing applications that rely on the TLS Keying Material (provided by
rustls::Session::export_keying_material
).Originally posted in rustls/hyper-rustls#146
cc @tiziano88
The text was updated successfully, but these errors were encountered: