update session update detection

This commit is contained in:
yggverse 2024-11-30 01:49:50 +02:00
parent b3e9bf239c
commit c3a76472d2

View file

@ -80,6 +80,7 @@ impl Client {
// Update previous session available for this request // Update previous session available for this request
match self.update_session(&uri, certificate.as_ref()) { match self.update_session(&uri, certificate.as_ref()) {
// Begin new connection
Ok(()) => match crate::gio::network_address::from_uri(&uri, crate::DEFAULT_PORT) { Ok(()) => match crate::gio::network_address::from_uri(&uri, crate::DEFAULT_PORT) {
Ok(network_address) => self.socket.connect_async( Ok(network_address) => self.socket.connect_async(
&network_address.clone(), &network_address.clone(),
@ -101,7 +102,7 @@ impl Client {
// Wrap connection to shared reference clone semantics // Wrap connection to shared reference clone semantics
let connection = Rc::new(connection); let connection = Rc::new(connection);
// Update session record // Update session
session.update(uri.to_string(), connection.clone()); session.update(uri.to_string(), connection.clone());
// Begin new request // Begin new request
@ -140,16 +141,31 @@ impl Client {
) -> Result<(), Error> { ) -> Result<(), Error> {
if let Some(connection) = self.session.get(&uri.to_string()) { if let Some(connection) = self.session.get(&uri.to_string()) {
// Check connection contain TLS authorization // Check connection contain TLS authorization
if let Some(ref tls_client_connection) = connection.tls_client_connection { match connection.tls_client_connection {
if let Some(new) = certificate { Some(ref tls_client_connection) => {
// Get previous certificate match certificate {
if let Some(ref old) = tls_client_connection.certificate() { Some(new) => {
if !new.is_same(old) { // Get previous certificate
// Prevent session resumption if let Some(ref old) = tls_client_connection.certificate() {
// Glib backend restore session in runtime with old certificate // User -> User
// @TODO keep in mind, until better solution found for TLS 1.3 if !new.is_same(old) {
println!("{:?}", tls_client_connection.handshake(Cancellable::NONE)); // Prevent session resumption
// Glib backend restore session in runtime with old certificate
// @TODO keep in mind, until better solution found for TLS 1.3
println!("{:?}", connection.rehandshake());
}
}
} }
None => {
// User -> Guest
println!("{:?}", connection.rehandshake());
}
}
}
None => {
// Guest -> User
if certificate.is_some() {
println!("{:?}", connection.rehandshake());
} }
} }
} }