x509_parser/validate/
name.rs1use crate::validate::*;
2use crate::x509::*;
3use asn1_rs::Tag;
4
5#[derive(Debug)]
6pub struct X509NameStructureValidator;
7
8impl<'a> Validator<'a> for X509NameStructureValidator {
9 type Item = X509Name<'a>;
10
11 fn validate<L: Logger>(&self, item: &'a Self::Item, l: &'_ mut L) -> bool {
12 let res = true;
13 for attr in item.iter_attributes() {
17 match attr.attr_value().tag() {
18 Tag::PrintableString | Tag::Ia5String => {
19 let b = attr.attr_value().as_bytes();
20 if !b.iter().all(u8::is_ascii) {
21 l.warn(&format!(
22 "Invalid charset in X.509 Name, component {}",
23 attr.attr_type()
24 ));
25 }
26 }
27 _ => (),
28 }
29 }
30 res
31 }
32}