diff --git a/src/app/browser/window/tab/item/page.rs b/src/app/browser/window/tab/item/page.rs index 41622c4e..471c079c 100644 --- a/src/app/browser/window/tab/item/page.rs +++ b/src/app/browser/window/tab/item/page.rs @@ -23,7 +23,7 @@ use crate::Profile; use gtk::{ gdk::Texture, gdk_pixbuf::Pixbuf, - gio::{Cancellable, SocketClientEvent, TlsCertificate}, + gio::{Cancellable, SocketClientEvent}, glib::{ gformat, GString, Priority, Regex, RegexCompileFlags, RegexMatchFlags, Uri, UriFlags, UriHideFlags, @@ -431,7 +431,7 @@ impl Page { Some(cancellable.clone()), // Search for user certificate match request match self.profile.identity.gemini.match_scope(&self.navigation.request.widget.entry.text()) { - Some(identity) => match TlsCertificate::from_pem(&identity.pem) { + Some(identity) => match identity.to_tls_certificate() { Ok(certificate) => Some(certificate), Err(reason) => todo!("{reason}"), }, diff --git a/src/profile/identity/gemini/identity.rs b/src/profile/identity/gemini/identity.rs index dfb08fbf..4c69cbfc 100644 --- a/src/profile/identity/gemini/identity.rs +++ b/src/profile/identity/gemini/identity.rs @@ -1,4 +1,18 @@ +mod error; +use error::Error; + +use gtk::gio::TlsCertificate; + pub struct Identity { pub pem: String, // pub scope: String, } + +impl Identity { + pub fn to_tls_certificate(&self) -> Result { + match TlsCertificate::from_pem(&self.pem) { + Ok(certificate) => Ok(certificate), + Err(reason) => Err(Error::TlsCertificate(reason)), + } + } +} diff --git a/src/profile/identity/gemini/identity/error.rs b/src/profile/identity/gemini/identity/error.rs new file mode 100644 index 00000000..f9ab509a --- /dev/null +++ b/src/profile/identity/gemini/identity/error.rs @@ -0,0 +1,15 @@ +use gtk::glib; +use std::fmt::{Display, Formatter, Result}; + +#[derive(Debug)] +pub enum Error { + TlsCertificate(glib::Error), +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter) -> Result { + match self { + Self::TlsCertificate(e) => write!(f, "TLS certificate error: {e}"), + } + } +}