@@ -43,7 +43,7 @@ fn load_der_x509_crl(
43
43
Ok ( CertificateRevocationList {
44
44
owned : Arc :: new ( owned) ,
45
45
revoked_certs : pyo3:: once_cell:: GILOnceCell :: new ( ) ,
46
- cached_extensions : None ,
46
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell :: new ( ) ,
47
47
} )
48
48
}
49
49
@@ -71,13 +71,12 @@ self_cell::self_cell!(
71
71
}
72
72
) ;
73
73
74
- // TODO: can't be frozen because extensions required `&mut self`.
75
- #[ pyo3:: prelude:: pyclass( module = "cryptography.hazmat.bindings._rust.x509" ) ]
74
+ #[ pyo3:: prelude:: pyclass( frozen, module = "cryptography.hazmat.bindings._rust.x509" ) ]
76
75
struct CertificateRevocationList {
77
76
owned : Arc < OwnedCertificateRevocationList > ,
78
77
79
78
revoked_certs : pyo3:: once_cell:: GILOnceCell < Vec < OwnedRevokedCertificate > > ,
80
- cached_extensions : Option < pyo3:: PyObject > ,
79
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell < pyo3:: PyObject > ,
81
80
}
82
81
83
82
impl CertificateRevocationList {
@@ -88,7 +87,7 @@ impl CertificateRevocationList {
88
87
fn revoked_cert ( & self , py : pyo3:: Python < ' _ > , idx : usize ) -> RevokedCertificate {
89
88
RevokedCertificate {
90
89
owned : self . revoked_certs . get ( py) . unwrap ( ) [ idx] . clone ( ) ,
91
- cached_extensions : None ,
90
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell :: new ( ) ,
92
91
}
93
92
}
94
93
@@ -270,13 +269,13 @@ impl CertificateRevocationList {
270
269
}
271
270
272
271
#[ getter]
273
- fn extensions ( & mut self , py : pyo3:: Python < ' _ > ) -> pyo3:: PyResult < pyo3:: PyObject > {
272
+ fn extensions ( & self , py : pyo3:: Python < ' _ > ) -> pyo3:: PyResult < pyo3:: PyObject > {
274
273
let tbs_cert_list = & self . owned . borrow_dependent ( ) . tbs_cert_list ;
275
274
276
275
let x509_module = py. import ( pyo3:: intern!( py, "cryptography.x509" ) ) ?;
277
276
x509:: parse_and_cache_extensions (
278
277
py,
279
- & mut self . cached_extensions ,
278
+ & self . cached_extensions ,
280
279
& tbs_cert_list. raw_crl_extensions ,
281
280
|ext| match ext. extn_id {
282
281
oid:: CRL_NUMBER_OID => {
@@ -359,7 +358,7 @@ impl CertificateRevocationList {
359
358
}
360
359
361
360
fn get_revoked_certificate_by_serial_number (
362
- & mut self ,
361
+ & self ,
363
362
py : pyo3:: Python < ' _ > ,
364
363
serial : & pyo3:: types:: PyLong ,
365
364
) -> pyo3:: PyResult < Option < RevokedCertificate > > {
@@ -381,7 +380,7 @@ impl CertificateRevocationList {
381
380
match owned {
382
381
Ok ( o) => Ok ( Some ( RevokedCertificate {
383
382
owned : o,
384
- cached_extensions : None ,
383
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell :: new ( ) ,
385
384
} ) ) ,
386
385
Err ( ( ) ) => Ok ( None ) ,
387
386
}
@@ -466,7 +465,7 @@ impl CRLIterator {
466
465
. ok ( ) ?;
467
466
Some ( RevokedCertificate {
468
467
owned : revoked,
469
- cached_extensions : None ,
468
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell :: new ( ) ,
470
469
} )
471
470
}
472
471
}
@@ -491,11 +490,10 @@ impl Clone for OwnedRevokedCertificate {
491
490
}
492
491
}
493
492
494
- // TODO: can't be frozen because extensions required `&mut self`.
495
- #[ pyo3:: prelude:: pyclass( module = "cryptography.hazmat.bindings._rust.x509" ) ]
493
+ #[ pyo3:: prelude:: pyclass( frozen, module = "cryptography.hazmat.bindings._rust.x509" ) ]
496
494
struct RevokedCertificate {
497
495
owned : OwnedRevokedCertificate ,
498
- cached_extensions : Option < pyo3:: PyObject > ,
496
+ cached_extensions : pyo3 :: once_cell :: GILOnceCell < pyo3:: PyObject > ,
499
497
}
500
498
501
499
#[ pyo3:: prelude:: pymethods]
@@ -517,10 +515,10 @@ impl RevokedCertificate {
517
515
}
518
516
519
517
#[ getter]
520
- fn extensions ( & mut self , py : pyo3:: Python < ' _ > ) -> pyo3:: PyResult < pyo3:: PyObject > {
518
+ fn extensions ( & self , py : pyo3:: Python < ' _ > ) -> pyo3:: PyResult < pyo3:: PyObject > {
521
519
x509:: parse_and_cache_extensions (
522
520
py,
523
- & mut self . cached_extensions ,
521
+ & self . cached_extensions ,
524
522
& self . owned . borrow_dependent ( ) . raw_crl_entry_extensions ,
525
523
|ext| parse_crl_entry_ext ( py, ext) ,
526
524
)
0 commit comments