MCPcopy Index your code
hub / github.com/RustPython/RustPython / process_san_general_names

Function process_san_general_names

crates/stdlib/src/ssl/cert.rs:229–262  ·  view source on GitHub ↗

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<'_>],
)

Source from the content-addressed store, hash-verified

227/// Converts X.509 GeneralName entries into Python tuple format.
228/// Returns a vector of PyObjectRef tuples in the format: (type, value)
229fn 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

Callers 1

cert_to_dictFunction · 0.85

Calls 6

format_ip_addressFunction · 0.85
collectMethod · 0.80
to_stringMethod · 0.80
SomeClass · 0.50
iterMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected