Skip to content

Commit

Permalink
feat: sorts tls certs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow committed Jan 8, 2024
1 parent 9811000 commit ee798d2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,15 @@ mod tls {
_ocsp_response: &[u8],
_now: SystemTime,
) -> Result<ServerCertVerified, TLSError> {
let mut certs = intermediates.iter().collect::<Vec<&Certificate>>();
certs.push(end_entity);
let mut certs = intermediates
.iter()
.map(|c| c.0.clone())
.collect::<Vec<Vec<u8>>>();
certs.push(end_entity.0.clone());
certs.sort();

let mut our_certs = self.certs.clone();
our_certs.sort();

if self.certs.len() != certs.len() {
return Err(TLSError::General(format!(
Expand All @@ -343,8 +350,8 @@ mod tls {
certs.len()
)));
}
for (c, p) in self.certs.iter().zip(certs.iter()) {
if *p.0 != **c {
for (c, p) in our_certs.iter().zip(certs.iter()) {
if *p != *c {
return Err(TLSError::General(
"Server certificates do not match ours".to_string(),
));
Expand Down

0 comments on commit ee798d2

Please sign in to comment.