replace deprecated in gio 2.72 set_tls_validation_flags method with custom validator

This commit is contained in:
yggverse 2024-11-19 19:11:09 +02:00
parent 090e39b976
commit a49ec2b7b4

View File

@ -22,7 +22,7 @@ use gtk::{
gdk_pixbuf::Pixbuf, gdk_pixbuf::Pixbuf,
gio::{ gio::{
Cancellable, IOStream, SocketClient, SocketClientEvent, SocketConnectable, SocketProtocol, Cancellable, IOStream, SocketClient, SocketClientEvent, SocketConnectable, SocketProtocol,
TlsCertificate, TlsCertificateFlags, TlsClientConnection, TlsCertificate, TlsClientConnection,
}, },
glib::{ glib::{
gformat, Bytes, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, gformat, Bytes, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri,
@ -466,8 +466,7 @@ impl Page {
Err(reason) => todo!("{reason}"), Err(reason) => todo!("{reason}"),
}, },
None => { None => {
// Use unauthorized connection // Use unauthorized TLS connection
client.set_tls_validation_flags(TlsCertificateFlags::INSECURE);
client.set_tls(true); client.set_tls(true);
None None
} }
@ -478,7 +477,7 @@ impl Page {
let update = update.clone(); let update = update.clone();
let id = id.clone(); let id = id.clone();
let meta = meta.clone(); let meta = meta.clone();
move |_, event, _, _| { move |_, event, _, stream| {
meta.set_status(match event { meta.set_status(match event {
SocketClientEvent::Resolving => Status::Resolving, SocketClientEvent::Resolving => Status::Resolving,
SocketClientEvent::Resolved => Status::Resolved, SocketClientEvent::Resolved => Status::Resolved,
@ -486,7 +485,17 @@ impl Page {
SocketClientEvent::Connected => Status::Connected, SocketClientEvent::Connected => Status::Connected,
SocketClientEvent::ProxyNegotiating => Status::ProxyNegotiating, SocketClientEvent::ProxyNegotiating => Status::ProxyNegotiating,
SocketClientEvent::ProxyNegotiated => Status::ProxyNegotiated, SocketClientEvent::ProxyNegotiated => Status::ProxyNegotiated,
SocketClientEvent::TlsHandshaking => Status::TlsHandshaking, SocketClientEvent::TlsHandshaking => {
// Handle certificate errors here
stream
.unwrap()
.dynamic_cast_ref::<TlsClientConnection>()
.unwrap()
.connect_accept_certificate(|_, _, _| {
true // @TODO
});
Status::TlsHandshaking
}
SocketClientEvent::TlsHandshaked => Status::TlsHandshaked, SocketClientEvent::TlsHandshaked => Status::TlsHandshaked,
SocketClientEvent::Complete => Status::Complete, SocketClientEvent::Complete => Status::Complete,
_ => todo!(), // notice on API change _ => todo!(), // notice on API change