From 01716c324bbf52d6cb8cfa585d1374c12289db1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 10 Oct 2023 14:09:31 -0700 Subject: [PATCH] Don't get cert twice --- src/MainWindow.vala | 13 ++++--------- src/TabbedWebView.vala | 3 +++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 6ca4d4a..d592d9c 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -163,23 +163,18 @@ public class Captive.MainWindow : Hdy.ApplicationWindow { cert_button.sensitive = web_view.security != NONE && web_view.security != LOADING; - TlsCertificate cert; - TlsCertificateFlags cert_flags; - - if (!web_view.get_tls_info (out cert, out cert_flags)) { + if (web_view.certificate == null) { cert_button.active = false; return; } - var gcr_cert = new Gcr.SimpleCertificate (cert.certificate.data); - cert_expiry.label = _("Expires %s").printf ( - gcr_cert.expiry_date.format (Granite.DateTime.get_default_date_format (false, true, true)) + web_view.certificate.expiry_date.format (Granite.DateTime.get_default_date_format (false, true, true)) ); - cert_issuer.label = _("Issued by ā€œ%sā€").printf (gcr_cert.issuer_name); + cert_issuer.label = _("Issued by ā€œ%sā€").printf (web_view.certificate.issuer_name); - cert_subject.label = gcr_cert.subject_name; + cert_subject.label = web_view.certificate.subject_name; } private bool is_privacy_mode_enabled () { diff --git a/src/TabbedWebView.vala b/src/TabbedWebView.vala index 1c000eb..2985846 100644 --- a/src/TabbedWebView.vala +++ b/src/TabbedWebView.vala @@ -21,6 +21,7 @@ public class Captive.TabbedWebView : WebKit.WebView { public bool load_cookies { get; construct; } public Security security { get; private set; } + public Gcr.SimpleCertificate? certificate { get; private set; default = null; } public enum Security { NONE, @@ -110,10 +111,12 @@ public class Captive.TabbedWebView : WebKit.WebView { if (!get_tls_info (out cert, out cert_flags)) { // The page is served over HTTP is_secure = false; + certificate = null; } else { // The page is served over HTTPS, if cert_flags is set then there's // some problem with the certificate provided by the website. is_secure = (cert_flags == 0); + certificate = new Gcr.SimpleCertificate (cert.certificate.data); } if (is_secure) {