Client cert verifier: return error if name does not match

This commit is contained in:
Nathan Fisher 2023-08-18 19:06:38 -04:00
parent 8cc3c13389
commit 67b7a2d0ea

View file

@ -1,6 +1,9 @@
use crate::{fingerprint::GetFingerprint, mailuser::Mailuser}; use crate::{fingerprint::GetFingerprint, mailuser::Mailuser};
use rustls::server::{ClientCertVerified, ClientCertVerifier}; use rustls::server::{ClientCertVerified, ClientCertVerifier};
use std::{sync::{Arc, Mutex}, io::Read}; use std::{
io::Read,
sync::{Arc, Mutex},
};
use x509_parser::prelude::*; use x509_parser::prelude::*;
#[derive(Debug)] #[derive(Debug)]
@ -40,6 +43,11 @@ impl<S: FingerPrintStore> ClientCertVerifier for Verifier<S> {
name_match = name == user.to_string(); name_match = name == user.to_string();
} }
}); });
if !name_match {
return Err(rustls::Error::InvalidCertificate(
rustls::CertificateError::NotValidForName,
));
}
} }
} }
todo!() todo!()