@@ -9,7 +9,7 @@ use cryptography_x509::common::{Asn1ReadableOrWritable, AttributeTypeValue, RawT
99use cryptography_x509:: extensions:: { AccessDescription , Extension , Extensions , RawExtensions } ;
1010use cryptography_x509:: name:: { GeneralName , Name , OtherName , UnvalidatedIA5String } ;
1111use pyo3:: types:: IntoPyDict ;
12- use pyo3:: { IntoPy , ToPyObject } ;
12+ use pyo3:: ToPyObject ;
1313
1414/// Parse all sections in a PEM file and return the first matching section.
1515/// If no matching sections are found, return an error.
@@ -397,16 +397,8 @@ pub(crate) fn parse_and_cache_extensions<
397397 return Ok ( cached. clone_ref ( py) ) ;
398398 }
399399
400- let extensions = match Extensions :: from_raw_extensions ( raw_extensions. as_ref ( ) ) {
401- Ok ( extensions) => extensions,
402- Err ( oid) => {
403- let oid_obj = oid_to_py_oid ( py, & oid) ?;
404- return Err ( exceptions:: DuplicateExtension :: new_err ( (
405- format ! ( "Duplicate {} extension found" , oid) ,
406- oid_obj. into_py ( py) ,
407- ) ) ) ;
408- }
409- } ;
400+ let extensions = Extensions :: from_raw_extensions ( raw_extensions. as_ref ( ) )
401+ . map_err ( CryptographyError :: from) ?;
410402
411403 let x509_module = py. import ( pyo3:: intern!( py, "cryptography.x509" ) ) ?;
412404 let exts = pyo3:: types:: PyList :: empty ( py) ;
0 commit comments