@@ -13,9 +13,10 @@ use cryptography_x509::certificate::Certificate as RawCertificate;
13
13
use cryptography_x509:: common:: { AlgorithmParameters , Asn1ReadableOrWritable } ;
14
14
use cryptography_x509:: extensions:: {
15
15
AuthorityKeyIdentifier , BasicConstraints , DisplayText , DistributionPoint ,
16
- DistributionPointName , IssuerAlternativeName , KeyUsage , MSCertificateTemplate , NameConstraints ,
17
- PolicyConstraints , PolicyInformation , PolicyQualifierInfo , Qualifier , RawExtensions ,
18
- SequenceOfAccessDescriptions , SequenceOfSubtrees , UserNotice ,
16
+ DistributionPointName , DuplicateExtensionsError , IssuerAlternativeName , KeyUsage ,
17
+ MSCertificateTemplate , NameConstraints , PolicyConstraints , PolicyInformation ,
18
+ PolicyQualifierInfo , Qualifier , RawExtensions , SequenceOfAccessDescriptions ,
19
+ SequenceOfSubtrees , UserNotice ,
19
20
} ;
20
21
use cryptography_x509:: extensions:: { Extension , SubjectAlternativeName } ;
21
22
use cryptography_x509:: { common, oid} ;
@@ -129,18 +130,14 @@ impl Certificate {
129
130
130
131
#[ getter]
131
132
fn issuer < ' p > ( & self , py : pyo3:: Python < ' p > ) -> pyo3:: PyResult < & ' p pyo3:: PyAny > {
132
- Ok (
133
- x509:: parse_name ( py, & self . raw . borrow_dependent ( ) . tbs_cert . issuer )
134
- . map_err ( |e| e. add_location ( asn1:: ParseLocation :: Field ( "issuer" ) ) ) ?,
135
- )
133
+ Ok ( x509:: parse_name ( py, self . raw . borrow_dependent ( ) . issuer ( ) )
134
+ . map_err ( |e| e. add_location ( asn1:: ParseLocation :: Field ( "issuer" ) ) ) ?)
136
135
}
137
136
138
137
#[ getter]
139
138
fn subject < ' p > ( & self , py : pyo3:: Python < ' p > ) -> pyo3:: PyResult < & ' p pyo3:: PyAny > {
140
- Ok (
141
- x509:: parse_name ( py, & self . raw . borrow_dependent ( ) . tbs_cert . subject )
142
- . map_err ( |e| e. add_location ( asn1:: ParseLocation :: Field ( "subject" ) ) ) ?,
143
- )
139
+ Ok ( x509:: parse_name ( py, self . raw . borrow_dependent ( ) . subject ( ) )
140
+ . map_err ( |e| e. add_location ( asn1:: ParseLocation :: Field ( "subject" ) ) ) ?)
144
141
}
145
142
146
143
#[ getter]
@@ -160,7 +157,7 @@ impl Certificate {
160
157
let val = self . raw . borrow_dependent ( ) ;
161
158
let mut tbs_precert = val. tbs_cert . clone ( ) ;
162
159
// Remove the SCT list extension
163
- match val. tbs_cert . extensions ( ) {
160
+ match val. extensions ( ) {
164
161
Ok ( extensions) => {
165
162
let ext_count = extensions
166
163
. as_raw ( )
@@ -185,10 +182,10 @@ impl Certificate {
185
182
let result = asn1:: write_single ( & tbs_precert) ?;
186
183
Ok ( pyo3:: types:: PyBytes :: new ( py, & result) )
187
184
}
188
- Err ( oid) => {
185
+ Err ( DuplicateExtensionsError ( oid) ) => {
189
186
let oid_obj = oid_to_py_oid ( py, & oid) ?;
190
187
Err ( exceptions:: DuplicateExtension :: new_err ( (
191
- format ! ( "Duplicate {} extension found" , oid) ,
188
+ format ! ( "Duplicate {} extension found" , & oid) ,
192
189
oid_obj. into_py ( py) ,
193
190
) )
194
191
. into ( ) )
0 commit comments