Skip to content

Commit 6e61445

Browse files
committed
PEP 748: disambiguate config trust_store=None
Client-side `trust_store=None` means `TrustStore.system()` but server-side it means "skip client authentication". One could think it means "skip server authentication" when used client-side, so let's not support `None` at all client-side and instead default to `TrustStore.system()`.
1 parent 6d41ae7 commit 6e61445

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

peps/pep-0748.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ The ``TLSClientConfiguration`` class would be defined by the following code:
276276
inner_protocols: Sequence[NextProtocol | bytes] | None = None,
277277
lowest_supported_version: TLSVersion | None = None,
278278
highest_supported_version: TLSVersion | None = None,
279-
trust_store: TrustStore | None = None,
279+
trust_store: TrustStore = TrustStore.system(),
280280
) -> None:
281281
if inner_protocols is None:
282282
inner_protocols = []
@@ -309,9 +309,13 @@ The ``TLSClientConfiguration`` class would be defined by the following code:
309309
return self._highest_supported_version
310310
311311
@property
312-
def trust_store(self) -> TrustStore | None:
312+
def trust_store(self) -> TrustStore:
313313
return self._trust_store
314314
315+
A ``trust_store`` is mandatory and is used to validate the server certificates.
316+
It uses the system's trust store by default. Insecure connections are only
317+
possible via the :ref:`insecure` module.
318+
315319
Server Configuration
316320
^^^^^^^^^^^^^^^^^^^^
317321

@@ -372,6 +376,9 @@ The ``TLSServerConfiguration`` class would be defined by the following code:
372376
def trust_store(self) -> TrustStore | None:
373377
return self._trust_store
374378
379+
A ``trust_store`` is optional. Setting one enables client authentication and
380+
uses the trust store to validate the client certificates. Leaving it ``None``
381+
disables client authentication.
375382

376383
Context
377384
~~~~~~~
@@ -1503,6 +1510,8 @@ Note that this function only needs to verify that supported constructors were
15031510
used for the certificates, private keys, and trust store. It does not need to
15041511
parse or retrieve the objects to validate them further.
15051512

1513+
.. _insecure:
1514+
15061515
Insecure Usage
15071516
--------------
15081517

0 commit comments

Comments
 (0)