| 144 | |
| 145 | impl Representable for PySSLCertificate { |
| 146 | fn repr_str(zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<String> { |
| 147 | // Build subject string like "CN=localhost, O=Python" |
| 148 | let subject = zelf.cert.subject_name(); |
| 149 | let mut parts: Vec<String> = Vec::new(); |
| 150 | for entry in subject.entries() { |
| 151 | // Use short name (SN) if available, otherwise use OID |
| 152 | let name = match entry.object().nid().short_name() { |
| 153 | Ok(sn) => sn.to_string(), |
| 154 | Err(_) => obj2txt(entry.object(), true).unwrap_or_default(), |
| 155 | }; |
| 156 | if let Ok(value) = entry.data().as_utf8() { |
| 157 | parts.push(format!("{}={}", name, value)); |
| 158 | } |
| 159 | } |
| 160 | if parts.is_empty() { |
| 161 | Ok("<Certificate>".to_string()) |
| 162 | } else { |
| 163 | Ok(format!("<Certificate '{}'>", parts.join(", "))) |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | fn name_to_py(vm: &VirtualMachine, name: &x509::X509NameRef) -> PyResult { |