Skip to content

Commit f4362f4

Browse files
woodruffwalex
andauthored
docs: add Store docs (#9416)
* docs: add Store docs Signed-off-by: William Woodruff <[email protected]> * src, tests: don't allow empty stores Signed-off-by: William Woodruff <[email protected]> * Update docs/x509/verification.rst Co-authored-by: Alex Gaynor <[email protected]> --------- Signed-off-by: William Woodruff <[email protected]> Co-authored-by: Alex Gaynor <[email protected]>
1 parent a6baece commit f4362f4

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

docs/x509/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ certificates are commonly used in protocols like `TLS`_.
1111
tutorial
1212
certificate-transparency
1313
ocsp
14+
verification
1415
reference
1516

1617
.. _`public key infrastructure`: https://en.wikipedia.org/wiki/Public_key_infrastructure

docs/x509/verification.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.

src/rust/src/x509/verify.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ struct PyStore(Vec<pyo3::Py<PyCertificate>>);
1515
impl PyStore {
1616
#[new]
1717
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+
}
1823
Ok(Self(certs))
1924
}
2025
}

tests/x509/test_verification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313

1414
class TestStore:
15+
def test_store_rejects_empty_list(self):
16+
with pytest.raises(ValueError):
17+
Store([])
18+
1519
def test_store_rejects_non_certificates(self):
1620
with pytest.raises(TypeError):
1721
Store(["not a cert"]) # type: ignore[list-item]

0 commit comments

Comments
 (0)