Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial code handling certificate #1

Merged
merged 5 commits into from
Jul 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions transports/tls-quic/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,26 @@ impl P2pCertificate<'_> {
// parameters ANY DEFINED BY algorithm OPTIONAL
// }
let pki = &self.certificate.tbs_certificate.subject_pki;
let algo_oid = if let Some(algo_oid) = pki.algorithm.algorithm.iter() {
yasna::models::ObjectIdentifier::new(algo_oid.collect())
} else {
return false;
};
let params_der = if let Some(params) = &pki.algorithm.parameters {
kpp marked this conversation as resolved.
Show resolved Hide resolved
if let Ok(der) = params.to_vec() {
Some(der)
} else {
return false
}
} else {
None
};
let subject_pki = yasna::construct_der(|writer| {
writer.write_sequence(|writer| {
writer.next().write_sequence(|writer| {
let oid = yasna::models::ObjectIdentifier::new(pki.algorithm.algorithm.iter().unwrap().collect());
writer.next().write_oid(&oid);
if let Some(params) = &pki.algorithm.parameters {
writer.next().write_der(&params.to_vec().unwrap());
writer.next().write_oid(&algo_oid);
if let Some(params_der) = params_der {
writer.next().write_der(&params_der);
}
});
writer.next().write_bitvec_bytes(&pki.subject_public_key.data, pki.subject_public_key.data.len() * 8);
Expand Down