(vm: &VirtualMachine, name: &x509::X509NameRef)
| 166 | } |
| 167 | |
| 168 | fn name_to_py(vm: &VirtualMachine, name: &x509::X509NameRef) -> PyResult { |
| 169 | let list = name |
| 170 | .entries() |
| 171 | .map(|entry| { |
| 172 | let txt = obj2txt(entry.object(), false).to_pyobject(vm); |
| 173 | let asn1_str = entry.data(); |
| 174 | let data_bytes = asn1_str.as_slice(); |
| 175 | let data = match std::str::from_utf8(data_bytes) { |
| 176 | Ok(s) => vm.ctx.new_str(s.to_owned()), |
| 177 | Err(_) => vm |
| 178 | .ctx |
| 179 | .new_str(String::from_utf8_lossy(data_bytes).into_owned()), |
| 180 | }; |
| 181 | Ok(vm.new_tuple(((txt, data),)).into()) |
| 182 | }) |
| 183 | .collect::<Result<_, _>>()?; |
| 184 | Ok(vm.ctx.new_tuple(list).into()) |
| 185 | } |
| 186 | |
| 187 | // Helper to convert X509 to dict (for getpeercert with binary=False) |
| 188 | fn cert_to_dict(vm: &VirtualMachine, cert: &X509Ref) -> PyResult { |
no test coverage detected