Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Zak <richard@profian.com>
  • Loading branch information
rjzak committed Sep 16, 2022
1 parent 9c8f106 commit e5e544e
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,22 +454,31 @@ mod tests {
}
};

let _cr_vec = match Vec::<CertReq<'_>>::from_der(&ret_vec) {
Ok(x) => x,
Err(e) => {
eprintln!("cr() error unpacking ASN1 array we just made {:?}", e);
Vec::new()
}
};

ret_vec
}

async fn attest_response(state: State, response: Response) {
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
eprintln!("attest_response() body len {}", body.as_ref().len());
let cr_vec = Vec::<Vec<u8>>::from_der(body.as_ref()).unwrap();
assert_eq!(cr_vec.len(), 1);
let path = PkiPath::from_der(&cr_vec[0]).unwrap();
eprintln!(
"attest_response() cr_vec shape: ({}, {})",
cr_vec.len(),
cr_vec[0].len()
);

match Certificate::from_der(&cr_vec[0]) {
Ok(_) => {
eprintln!("Converted cr_vec[0] to cert, shouldn't have been possible!");
}
Err(_) => {
eprintln!("Could not make cr_vec[0] to cert, this is good, actually.");
}
}

//let path = PkiPath::from_der(&cr_vec[0]).unwrap();
let path = Vec::<Certificate<'_>>::from_der(cr_vec[0].as_ref()).unwrap();
let issr = Certificate::from_der(&state.crt).unwrap();
assert_eq!(2, path.len());
assert_eq!(issr, path[0]);
Expand All @@ -480,10 +489,10 @@ mod tests {
fn reencode() {
let encoded = cr(SECP_256_R_1, vec![]);

for byte in &encoded {
/*for byte in &encoded {
eprint!("{:02X}", byte);
}
eprintln!();
eprintln!();*/

let cr_vec: Vec<Vec<u8>> = Decode::from_der(&encoded).unwrap();
assert_eq!(cr_vec.len(), 1);
Expand Down

0 comments on commit e5e544e

Please sign in to comment.