From a49ec2b7b4b1cca36b78b389172d55712f5a97e7 Mon Sep 17 00:00:00 2001
From: yggverse <yggverse@project>
Date: Tue, 19 Nov 2024 19:11:09 +0200
Subject: [PATCH] replace deprecated in gio 2.72 set_tls_validation_flags
 method with custom validator

---
 src/app/browser/window/tab/item/page.rs | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs
index e8d0c336..0f14ba31 100644
--- a/src/app/browser/window/tab/item/page.rs
+++ b/src/app/browser/window/tab/item/page.rs
@@ -22,7 +22,7 @@ use gtk::{
     gdk_pixbuf::Pixbuf,
     gio::{
         Cancellable, IOStream, SocketClient, SocketClientEvent, SocketConnectable, SocketProtocol,
-        TlsCertificate, TlsCertificateFlags, TlsClientConnection,
+        TlsCertificate, TlsClientConnection,
     },
     glib::{
         gformat, Bytes, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri,
@@ -466,8 +466,7 @@ impl Page {
                 Err(reason) => todo!("{reason}"),
             },
             None => {
-                // Use unauthorized connection
-                client.set_tls_validation_flags(TlsCertificateFlags::INSECURE);
+                // Use unauthorized TLS connection
                 client.set_tls(true);
                 None
             }
@@ -478,7 +477,7 @@ impl Page {
             let update = update.clone();
             let id = id.clone();
             let meta = meta.clone();
-            move |_, event, _, _| {
+            move |_, event, _, stream| {
                 meta.set_status(match event {
                     SocketClientEvent::Resolving => Status::Resolving,
                     SocketClientEvent::Resolved => Status::Resolved,
@@ -486,7 +485,17 @@ impl Page {
                     SocketClientEvent::Connected => Status::Connected,
                     SocketClientEvent::ProxyNegotiating => Status::ProxyNegotiating,
                     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::Complete => Status::Complete,
                     _ => todo!(), // notice on API change