Process Subject Alternative Name (SAN) general names into Python tuples Converts X.509 GeneralName entries into Python tuple format. Returns a vector of PyObjectRef tuples in the format: (type, value)
(
vm: &VirtualMachine,
general_names: &[GeneralName<'_>],
)
| 227 | /// Converts X.509 GeneralName entries into Python tuple format. |
| 228 | /// Returns a vector of PyObjectRef tuples in the format: (type, value) |
| 229 | fn process_san_general_names( |
| 230 | vm: &VirtualMachine, |
| 231 | general_names: &[GeneralName<'_>], |
| 232 | ) -> Vec<PyObjectRef> { |
| 233 | general_names |
| 234 | .iter() |
| 235 | .filter_map(|name| match name { |
| 236 | GeneralName::DNSName(dns) => Some(vm.new_tuple(("DNS", *dns)).into()), |
| 237 | GeneralName::IPAddress(ip) => { |
| 238 | let ip_str = format_ip_address(ip); |
| 239 | Some(vm.new_tuple(("IP Address", ip_str)).into()) |
| 240 | } |
| 241 | GeneralName::RFC822Name(email) => Some(vm.new_tuple(("email", *email)).into()), |
| 242 | GeneralName::URI(uri) => Some(vm.new_tuple(("URI", *uri)).into()), |
| 243 | GeneralName::DirectoryName(dn) => { |
| 244 | let dn_str = format!("{dn}"); |
| 245 | Some(vm.new_tuple(("DirName", dn_str)).into()) |
| 246 | } |
| 247 | GeneralName::RegisteredID(oid) => { |
| 248 | let oid_str = oid.to_string(); |
| 249 | Some(vm.new_tuple(("Registered ID", oid_str)).into()) |
| 250 | } |
| 251 | GeneralName::OtherName(oid, value) => { |
| 252 | let oid_str = oid.to_string(); |
| 253 | let value_str = format!("{value:?}"); |
| 254 | Some( |
| 255 | vm.new_tuple(("othername", format!("{oid_str}:{value_str}"))) |
| 256 | .into(), |
| 257 | ) |
| 258 | } |
| 259 | _ => None, |
| 260 | }) |
| 261 | .collect() |
| 262 | } |
| 263 | |
| 264 | // Certificate Validation and Parsing |
| 265 |
no test coverage detected