diff --git a/src/rust/src/x509/certificate.rs b/src/rust/src/x509/certificate.rs index 3f24c811a662..64c9ac85b102 100644 --- a/src/rust/src/x509/certificate.rs +++ b/src/rust/src/x509/certificate.rs @@ -130,18 +130,14 @@ impl Certificate { #[getter] fn issuer<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::PyAny> { - Ok( - x509::parse_name(py, &self.raw.borrow_dependent().tbs_cert.issuer) - .map_err(|e| e.add_location(asn1::ParseLocation::Field("issuer")))?, - ) + Ok(x509::parse_name(py, &self.raw.borrow_dependent().issuer()) + .map_err(|e| e.add_location(asn1::ParseLocation::Field("issuer")))?) } #[getter] fn subject<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::PyAny> { - Ok( - x509::parse_name(py, &self.raw.borrow_dependent().tbs_cert.subject) - .map_err(|e| e.add_location(asn1::ParseLocation::Field("subject")))?, - ) + Ok(x509::parse_name(py, &self.raw.borrow_dependent().subject()) + .map_err(|e| e.add_location(asn1::ParseLocation::Field("subject")))?) } #[getter] diff --git a/src/rust/src/x509/common.rs b/src/rust/src/x509/common.rs index 172f94a02914..ead503b945bb 100644 --- a/src/rust/src/x509/common.rs +++ b/src/rust/src/x509/common.rs @@ -9,7 +9,7 @@ use cryptography_x509::common::{Asn1ReadableOrWritable, AttributeTypeValue, RawT use cryptography_x509::extensions::{ AccessDescription, DuplicateExtensionsError, Extension, Extensions, RawExtensions, }; -use cryptography_x509::name::{GeneralName, Name, OtherName, UnvalidatedIA5String}; +use cryptography_x509::name::{GeneralName, Name, NameReadable, OtherName, UnvalidatedIA5String}; use pyo3::types::IntoPyDict; use pyo3::{IntoPy, ToPyObject}; @@ -175,11 +175,11 @@ pub(crate) fn encode_access_descriptions<'a>( pub(crate) fn parse_name<'p>( py: pyo3::Python<'p>, - name: &Name<'_>, + name: &NameReadable<'_>, ) -> Result<&'p pyo3::PyAny, CryptographyError> { let x509_module = py.import(pyo3::intern!(py, "cryptography.x509"))?; let py_rdns = pyo3::types::PyList::empty(py); - for rdn in name.unwrap_read().clone() { + for rdn in name.clone() { let py_rdn = parse_rdn(py, &rdn)?; py_rdns.append(py_rdn)?; } @@ -274,7 +274,7 @@ pub(crate) fn parse_general_name( .call_method1(pyo3::intern!(py, "_init_without_validation"), (data.0,))? .to_object(py), GeneralName::DirectoryName(data) => { - let py_name = parse_name(py, &data)?; + let py_name = parse_name(py, &data.unwrap_read())?; x509_module .call_method1(pyo3::intern!(py, "DirectoryName"), (py_name,))? .to_object(py) diff --git a/src/rust/src/x509/crl.rs b/src/rust/src/x509/crl.rs index fbb7b4668bb1..4c372e0cefe5 100644 --- a/src/rust/src/x509/crl.rs +++ b/src/rust/src/x509/crl.rs @@ -240,7 +240,12 @@ impl CertificateRevocationList { fn issuer<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::PyAny> { Ok(x509::parse_name( py, - &self.owned.borrow_dependent().tbs_cert_list.issuer, + &self + .owned + .borrow_dependent() + .tbs_cert_list + .issuer + .unwrap_read(), )?) } diff --git a/src/rust/src/x509/csr.rs b/src/rust/src/x509/csr.rs index 0df274c3e693..7ff9d76a68a7 100644 --- a/src/rust/src/x509/csr.rs +++ b/src/rust/src/x509/csr.rs @@ -74,7 +74,7 @@ impl CertificateSigningRequest { fn subject<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::PyAny> { Ok(x509::parse_name( py, - &self.raw.borrow_dependent().csr_info.subject, + &self.raw.borrow_dependent().csr_info.subject.unwrap_read(), )?) } diff --git a/src/rust/src/x509/ocsp_resp.rs b/src/rust/src/x509/ocsp_resp.rs index abb32d526392..49cd67fda8aa 100644 --- a/src/rust/src/x509/ocsp_resp.rs +++ b/src/rust/src/x509/ocsp_resp.rs @@ -147,7 +147,9 @@ impl OCSPResponse { fn responder_name<'p>(&self, py: pyo3::Python<'p>) -> pyo3::PyResult<&'p pyo3::PyAny> { let resp = self.requires_successful_response()?; match resp.tbs_response_data.responder_id { - ocsp_resp::ResponderId::ByName(ref name) => Ok(x509::parse_name(py, name)?), + ocsp_resp::ResponderId::ByName(ref name) => { + Ok(x509::parse_name(py, name.unwrap_read())?) + } ocsp_resp::ResponderId::ByKey(_) => Ok(py.None().into_ref(py)), } }