From 21961ad75679f00ee04f9529c1fdfb39f842ad23 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Sun, 25 Jun 2023 16:31:17 +1000 Subject: [PATCH] implement Into for Trusted --- libs/tls/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/tls/src/lib.rs b/libs/tls/src/lib.rs index d1cc5e5de..3736c99b4 100644 --- a/libs/tls/src/lib.rs +++ b/libs/tls/src/lib.rs @@ -6,8 +6,9 @@ use rkyv::{ ser::{serializers::WriteSerializer, Serializer}, AlignedVec, Archive, Deserialize, Serialize, }; -use rustls::Certificate; +use rustls::{Certificate, DistinguishedName, RootCertStore}; use std::convert::TryFrom; +use std::convert::{Into, TryFrom}; use std::fs::File; use std::io::{Error, ErrorKind, Read, Write}; use std::path::PathBuf; @@ -105,6 +106,15 @@ impl Iterator for Trusted { } } +impl Into for Trusted { + fn into(self) -> RootCertStore { + let mut root_store = rustls::RootCertStore::empty(); + let trusted = Trusted::new().unwrap(); + root_store + .add_server_trust_anchors(trusted.map(|t| Into::::into(t))); + root_store + } +} // presents a modal to the user to select trusted tls certificates // and saves the selected certificates to the pddb