File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ certificates are commonly used in protocols like `TLS`_.
11
11
tutorial
12
12
certificate-transparency
13
13
ocsp
14
+ verification
14
15
reference
15
16
16
17
.. _`public key infrastructure` : https://en.wikipedia.org/wiki/Public_key_infrastructure
Original file line number Diff line number Diff line change
1
+ X.509 verification
2
+ ==================
3
+
4
+ .. currentmodule :: cryptography.x509.verification
5
+
6
+ Support for X.509 certificate verification, also known as path validation,
7
+ chain building, etc.
8
+
9
+ .. note ::
10
+ This module is a work in progress, and does not yet contain a fully usable
11
+ X.509 path validation implementation.
12
+
13
+ .. class :: Store(certs)
14
+
15
+ .. versionadded :: 42.0.0
16
+
17
+ A Store is an opaque set of public keys and subject identifiers that are
18
+ considered trusted *a priori *. Stores are typically created from the host
19
+ OS's root of trust, from a well-known source such as a browser CA bundle,
20
+ or from a small set of manually pre-trusted entities.
21
+
22
+ :param certs: A list of one or more :class: `~cryptography.x509.Certificate `
23
+ instances.
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ struct PyStore(Vec<pyo3::Py<PyCertificate>>);
15
15
impl PyStore {
16
16
#[ new]
17
17
fn new ( certs : Vec < pyo3:: Py < PyCertificate > > ) -> pyo3:: PyResult < Self > {
18
+ if certs. is_empty ( ) {
19
+ return Err ( pyo3:: exceptions:: PyValueError :: new_err (
20
+ "can't create an empty store" ,
21
+ ) ) ;
22
+ }
18
23
Ok ( Self ( certs) )
19
24
}
20
25
}
Original file line number Diff line number Diff line change 12
12
13
13
14
14
class TestStore :
15
+ def test_store_rejects_empty_list (self ):
16
+ with pytest .raises (ValueError ):
17
+ Store ([])
18
+
15
19
def test_store_rejects_non_certificates (self ):
16
20
with pytest .raises (TypeError ):
17
21
Store (["not a cert" ]) # type: ignore[list-item]
You can’t perform that action at this time.
0 commit comments