mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-04 04:27:34 +00:00
implement tls RustlsOwnedTrustAnchor::subject()
This commit is contained in:
parent
42eb72b3bd
commit
be9f0fd29a
1 changed files with 13 additions and 1 deletions
|
|
@ -6,13 +6,14 @@ use rkyv::{
|
|||
ser::{serializers::WriteSerializer, Serializer},
|
||||
AlignedVec, Archive, Deserialize, Serialize,
|
||||
};
|
||||
use rustls::{Certificate, DistinguishedName, RootCertStore};
|
||||
use rustls::{Certificate, RootCertStore};
|
||||
use std::cmp::min;
|
||||
use std::convert::{Into, TryFrom};
|
||||
use std::fs::File;
|
||||
use std::io::{Error, ErrorKind, Read, Write};
|
||||
use std::path::PathBuf;
|
||||
use x509_parser::prelude::{FromDer, X509Certificate};
|
||||
use x509_parser::der_parser::der::Tag;
|
||||
use xous_names::XousNames;
|
||||
|
||||
/// PDDB Dict for tls trusted certificates keys
|
||||
|
|
@ -41,6 +42,17 @@ pub fn from_subject_spki_name_constraints(
|
|||
}
|
||||
|
||||
|
||||
pub fn subject(&self) -> String {
|
||||
let der = self.subject.clone();
|
||||
let len = min(der.len(), 127);
|
||||
let mut der = der[..len].to_owned();
|
||||
der.insert(0, len as u8);
|
||||
der.insert(0, Tag::Sequence.0 as u8);
|
||||
match x509_parser::x509::X509Name::from_der(&der) {
|
||||
Ok((_, decoded)) => decoded.to_string(),
|
||||
Err(e) => format!("der parse failed: {e}").to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue