remove extra certificate holder

This commit is contained in:
yggverse 2024-12-01 03:04:01 +02:00
parent 3cc9fcd86b
commit 273dac139e

View file

@ -9,7 +9,6 @@ use glib::object::{Cast, IsA, ObjectExt};
pub struct Connection { pub struct Connection {
pub cancellable: Option<Cancellable>, pub cancellable: Option<Cancellable>,
pub certificate: Option<TlsCertificate>,
pub socket_connection: SocketConnection, pub socket_connection: SocketConnection,
pub tls_client_connection: TlsClientConnection, pub tls_client_connection: TlsClientConnection,
} }
@ -30,7 +29,6 @@ impl Connection {
Ok(Self { Ok(Self {
cancellable, cancellable,
certificate: certificate.clone(),
socket_connection: socket_connection.clone(), socket_connection: socket_connection.clone(),
tls_client_connection: match TlsClientConnection::new( tls_client_connection: match TlsClientConnection::new(
&socket_connection.clone(), &socket_connection.clone(),
@ -91,10 +89,10 @@ impl Connection {
/// * useful also to keep `Connection` active in async I/O context /// * useful also to keep `Connection` active in async I/O context
pub fn stream(&self) -> impl IsA<IOStream> { pub fn stream(&self) -> impl IsA<IOStream> {
// * do not replace with `tls_client_connection.base_io_stream()` // * do not replace with `tls_client_connection.base_io_stream()`
// as it will not work for user certificate sessions! // as it will not work properly for user certificate sessions!
match self.certificate { match self.tls_client_connection.certificate().is_some() {
Some(_) => self.tls_client_connection.clone().upcast::<IOStream>(), true => self.tls_client_connection.clone().upcast::<IOStream>(),
None => self.socket_connection.clone().upcast::<IOStream>(), false => self.socket_connection.clone().upcast::<IOStream>(),
} }
} }
} }