mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
include broken tls::rota::public_key()
This commit is contained in:
parent
a5ef4585a8
commit
4e0298c17a
2 changed files with 20 additions and 3 deletions
|
|
@ -134,8 +134,6 @@ impl Tls {
|
|||
|
||||
// saves a tls trust-anchor to the pddb
|
||||
pub fn save_cert(&self, ta: &RustlsOwnedTrustAnchor) -> Result<(), Error> {
|
||||
// let xns = XousNames::new().unwrap();
|
||||
// let modals = Modals::new(&xns).unwrap();
|
||||
let key = ta.pddb_key();
|
||||
match self.pddb.get(
|
||||
TLS_TRUSTED_DICT,
|
||||
|
|
@ -163,7 +161,6 @@ impl Tls {
|
|||
let pos_bytes = pos.to_be_bytes();
|
||||
bytes[0] = pos_bytes[0];
|
||||
bytes[1] = pos_bytes[1];
|
||||
|
||||
match pddb_key.write(&bytes) {
|
||||
Ok(len) => {
|
||||
self.pddb.sync().ok();
|
||||
|
|
|
|||
|
|
@ -50,6 +50,26 @@ impl RustlsOwnedTrustAnchor {
|
|||
}
|
||||
}
|
||||
|
||||
// decoded public key
|
||||
// see https://docs.rs/x509-parser/0.15.0/src/x509_parser/x509.rs.html#260-274
|
||||
#[allow(unreachable_code)]
|
||||
pub fn public_key(&self) -> Result<Vec<u8>, Error> {
|
||||
todo!(); // fails decode
|
||||
match add_der_header(Tag::Sequence, &self.spki) {
|
||||
Ok(der) => match x509_parser::x509::SubjectPublicKeyInfo::from_der(&der) {
|
||||
Ok((_, spki)) => Ok(spki.subject_public_key.data.to_vec()),
|
||||
Err(e) => {
|
||||
log::warn!("{:?}", e);
|
||||
Err(Error::new(ErrorKind::InvalidData, "failed spki der decode"))
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
log::warn!("{:?}", e.into_inner().unwrap());
|
||||
Err(Error::new(ErrorKind::InvalidData, "failed spki der header"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pddb_key(&self) -> String {
|
||||
let subject = &self.subject();
|
||||
let begin = match subject.find("CN=") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue