Skip to content

Commit cb6c0a3

Browse files
authored
Remove driver config option trust (#1177)
Remove deprecated driver configuration option `trust`. Use `trusted_certificates` instead. Remove the associated constants `neo4j.TRUST_ALL_CERTIFICATES` and `neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES`.
1 parent fde060c commit cb6c0a3

File tree

14 files changed

+15
-301
lines changed

14 files changed

+15
-301
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
5656
If you were calling it directly, please use `Record.__getitem__(slice(...))` or simply `record[...]` instead.
5757
- Remove deprecated class `neo4j.Bookmark` in favor of `neo4j.Bookmarks`.
5858
- Remove deprecated class `session.last_bookmark()` in favor of `last_bookmarks()`.
59+
- Remove deprecated driver configuration option `trust`.
60+
Use `trusted_certificates` instead.
61+
- Remove the associated constants `neo4j.TRUST_ALL_CERTIFICATES` and `neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES`.
5962
- Make undocumented classes `ResolvedAddress`, `ResolvedIPv4Address`, and `ResolvedIPv6Address` private.
6063
- Rework `PreviewWarning`.
6164
- Remove `ExperimentalWarning` and turn the few left instances of it into `PreviewWarning`.

docs/source/api.rst

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ Additional configuration can be provided via the :class:`neo4j.Driver` construct
401401
+ :ref:`max-connection-pool-size-ref`
402402
+ :ref:`max-transaction-retry-time-ref`
403403
+ :ref:`resolver-ref`
404-
+ :ref:`trust-ref`
405404
+ :ref:`ssl-context-ref`
406405
+ :ref:`trusted-certificates-ref`
407406
+ :ref:`client-certificate-ref`
@@ -568,39 +567,6 @@ For example:
568567
:Default: :data:`None`
569568

570569

571-
.. _trust-ref:
572-
573-
``trust``
574-
---------
575-
Specify how to determine the authenticity of encryption certificates provided by the Neo4j instance on connection.
576-
577-
This setting is only available for URI schemes ``bolt://`` and ``neo4j://`` (:ref:`uri-ref`).
578-
579-
This setting does not have any effect if ``encrypted`` is set to ``False`` or a
580-
custom ``ssl_context`` is configured.
581-
582-
:Type: ``neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES``, ``neo4j.TRUST_ALL_CERTIFICATES``
583-
584-
.. py:attribute:: neo4j.TRUST_ALL_CERTIFICATES
585-
586-
Trust any server certificate (default). This ensures that communication
587-
is encrypted but does not verify the server certificate against a
588-
certificate authority. This option is primarily intended for use with
589-
the default auto-generated server certificate.
590-
591-
.. py:attribute:: neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES
592-
593-
Trust server certificates that can be verified against the system
594-
certificate authority. This option is primarily intended for use with
595-
full certificates.
596-
597-
:Default: ``neo4j.TRUST_SYSTEM_CA_SIGNED_CERTIFICATES``.
598-
599-
.. deprecated:: 5.0
600-
This configuration option is deprecated and will be removed in a future
601-
release. Please use :ref:`trusted-certificates-ref` instead.
602-
603-
604570
.. _ssl-context-ref:
605571

606572
``ssl_context``

src/neo4j/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103
READ_ACCESS,
104104
ServerInfo,
105105
SYSTEM_DATABASE,
106-
TRUST_ALL_CERTIFICATES,
107-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
108106
WRITE_ACCESS,
109107
)
110108

@@ -113,8 +111,6 @@
113111
"DEFAULT_DATABASE",
114112
"READ_ACCESS",
115113
"SYSTEM_DATABASE",
116-
"TRUST_ALL_CERTIFICATES",
117-
"TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
118114
"WRITE_ACCESS",
119115
"Address",
120116
"AsyncBoltDriver",

src/neo4j/_async/config.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
from .._async_compat.concurrency import AsyncLock
2222
from .._conf import (
23-
_trust_to_trusted_certificates,
2423
Config,
25-
DeprecatedAlternative,
2624
TrustAll,
2725
TrustCustomCAs,
2826
TrustSystemCAs,
@@ -57,13 +55,6 @@ class AsyncPoolConfig(Config):
5755
# The maximum amount of time to wait for a TCP connection to be
5856
# established.
5957

60-
#: Trust
61-
trust = DeprecatedAlternative(
62-
"trusted_certificates", _trust_to_trusted_certificates
63-
)
64-
# Specify how to determine the authenticity of encryption certificates
65-
# provided by the Neo4j instance on connection.
66-
6758
#: Custom Resolver
6859
resolver = None
6960
# Custom resolver function, returning list of resolved addresses.

src/neo4j/_async/driver.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
parse_routing_context,
6969
READ_ACCESS,
7070
ServerInfo,
71-
TRUST_ALL_CERTIFICATES,
72-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
7371
URI_SCHEME_BOLT,
7472
URI_SCHEME_BOLT_SECURE,
7573
URI_SCHEME_BOLT_SELF_SIGNED_CERTIFICATE,
@@ -134,10 +132,6 @@ def driver(
134132
liveness_check_timeout: float | None = ...,
135133
max_connection_pool_size: int = ...,
136134
connection_timeout: float = ...,
137-
trust: (
138-
te.Literal["TRUST_ALL_CERTIFICATES"]
139-
| te.Literal["TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"]
140-
) = ...,
141135
resolver: (
142136
t.Callable[[Address], t.Iterable[Address]]
143137
| t.Callable[[Address], t.Awaitable[t.Iterable[Address]]]
@@ -213,20 +207,6 @@ def driver(
213207
_AsyncStaticClientCertificateProvider(client_certificate)
214208
)
215209

216-
# TODO: 6.0 - remove "trust" config option
217-
if "trust" in config and config["trust"] not in {
218-
TRUST_ALL_CERTIFICATES,
219-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
220-
}:
221-
raise ConfigurationError(
222-
"The config setting `trust` values are {!r}".format(
223-
[
224-
TRUST_ALL_CERTIFICATES,
225-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
226-
]
227-
)
228-
)
229-
230210
if "trusted_certificates" in config and not isinstance(
231211
config["trusted_certificates"], TrustStore
232212
):
@@ -243,16 +223,14 @@ def driver(
243223
SECURITY_TYPE_SECURE,
244224
} and (
245225
"encrypted" in config
246-
or "trust" in config
247226
or "trusted_certificates" in config
248227
or "ssl_context" in config
249228
):
250-
# TODO: 6.0 - remove "trust" from error message
251229
raise ConfigurationError(
252-
'The config settings "encrypted", "trust", '
253-
'"trusted_certificates", and "ssl_context" can only be '
254-
"used with the URI schemes {!r}. Use the other URI "
255-
"schemes {!r} for setting encryption settings.".format(
230+
'The config settings "encrypted", "trusted_certificates", '
231+
'and "ssl_context" can only be used with the URI schemes '
232+
"{!r}. Use the other URI schemes {!r} for setting "
233+
"encryption settings.".format(
256234
[
257235
URI_SCHEME_BOLT,
258236
URI_SCHEME_NEO4J,

src/neo4j/_conf.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
)
2626
from .api import (
2727
DEFAULT_DATABASE,
28-
TRUST_ALL_CERTIFICATES,
29-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
3028
WRITE_ACCESS,
3129
)
3230
from .exceptions import ConfigurationError
@@ -344,13 +342,6 @@ def __iter__(self):
344342
return iter(self.keys())
345343

346344

347-
def _trust_to_trusted_certificates(pool_config, trust):
348-
if trust == TRUST_SYSTEM_CA_SIGNED_CERTIFICATES:
349-
pool_config.trusted_certificates = TrustSystemCAs()
350-
elif trust == TRUST_ALL_CERTIFICATES:
351-
pool_config.trusted_certificates = TrustAll()
352-
353-
354345
class WorkspaceConfig(Config):
355346
"""WorkSpace configuration."""
356347

src/neo4j/_sync/config.py

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j/_sync/driver.py

Lines changed: 4 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j/api.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
"DEFAULT_DATABASE",
4848
"READ_ACCESS",
4949
"SYSTEM_DATABASE",
50-
"TRUST_ALL_CERTIFICATES",
51-
"TRUST_SYSTEM_CA_SIGNED_CERTIFICATES",
5250
"URI_SCHEME_BOLT",
5351
"URI_SCHEME_BOLT_ROUTING",
5452
"URI_SCHEME_BOLT_SECURE",
@@ -86,12 +84,6 @@
8684

8785
URI_SCHEME_BOLT_ROUTING: te.Final[str] = "bolt+routing"
8886

89-
# TODO: 6.0 - remove TRUST constants
90-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES: te.Final[str] = (
91-
"TRUST_SYSTEM_CA_SIGNED_CERTIFICATES" # Default
92-
)
93-
TRUST_ALL_CERTIFICATES: te.Final[str] = "TRUST_ALL_CERTIFICATES"
94-
9587
SYSTEM_DATABASE: te.Final[str] = "system"
9688
DEFAULT_DATABASE: te.Final[None] = None # Must be a non string hashable value
9789

tests/unit/async_/test_conf.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
Config,
2929
SessionConfig,
3030
)
31-
from neo4j.api import (
32-
TRUST_ALL_CERTIFICATES,
33-
TRUST_SYSTEM_CA_SIGNED_CERTIFICATES,
34-
)
3531
from neo4j.auth_management import (
3632
AsyncClientCertificateProviders,
3733
ClientCertificate,
@@ -146,52 +142,6 @@ def test_pool_config_consume_and_then_consume_again():
146142
assert consumed_pool_config.encrypted == "test"
147143

148144

149-
@pytest.mark.parametrize(
150-
("value_trust", "expected_trusted_certificates_cls"),
151-
(
152-
(TRUST_ALL_CERTIFICATES, TrustAll),
153-
(TRUST_SYSTEM_CA_SIGNED_CERTIFICATES, TrustSystemCAs),
154-
),
155-
)
156-
def test_pool_config_deprecated_trust_config(
157-
value_trust, expected_trusted_certificates_cls
158-
):
159-
with pytest.warns(DeprecationWarning, match="trust.*trusted_certificates"):
160-
consumed_pool_config = AsyncPoolConfig.consume({"trust": value_trust})
161-
assert isinstance(
162-
consumed_pool_config.trusted_certificates,
163-
expected_trusted_certificates_cls,
164-
)
165-
assert not hasattr(consumed_pool_config, "trust")
166-
167-
168-
@pytest.mark.parametrize(
169-
"value_trust",
170-
(TRUST_ALL_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATES),
171-
)
172-
@pytest.mark.parametrize(
173-
"trusted_certificates",
174-
(
175-
TrustSystemCAs(),
176-
TrustAll(),
177-
TrustCustomCAs("foo"),
178-
TrustCustomCAs("foo", "bar"),
179-
),
180-
)
181-
def test_pool_config_deprecated_and_new_trust_config(
182-
value_trust, trusted_certificates
183-
):
184-
with pytest.raises(
185-
ConfigurationError, match="trusted_certificates.*trust"
186-
):
187-
AsyncPoolConfig.consume(
188-
{
189-
"trust": value_trust,
190-
"trusted_certificates": trusted_certificates,
191-
}
192-
)
193-
194-
195145
def test_config_consume_chain():
196146
test_config = {}
197147

0 commit comments

Comments
 (0)