|
19 | 19 | from abc import ABCMeta |
20 | 20 | from collections.abc import Mapping |
21 | 21 |
|
22 | | -from .__conf import ( |
23 | | - TrustAll, |
24 | | - TrustCustomCAs, |
25 | | - TrustSystemCAs, |
26 | | -) |
27 | 22 | from ._meta import ( |
28 | 23 | deprecation_warn, |
29 | 24 | get_user_agent, |
@@ -52,6 +47,76 @@ def iter_items(iterable): |
52 | 47 | yield key, value |
53 | 48 |
|
54 | 49 |
|
| 50 | +class TrustStore: |
| 51 | + # Base class for trust stores. For internal type-checking only. |
| 52 | + pass |
| 53 | + |
| 54 | + |
| 55 | +class TrustSystemCAs(TrustStore): |
| 56 | + """Used to configure the driver to trust system CAs (default). |
| 57 | +
|
| 58 | + Trust server certificates that can be verified against the system |
| 59 | + certificate authority. This option is primarily intended for use with |
| 60 | + full certificates. |
| 61 | +
|
| 62 | + For example:: |
| 63 | +
|
| 64 | + import neo4j |
| 65 | +
|
| 66 | + driver = neo4j.GraphDatabase.driver( |
| 67 | + url, auth=auth, trusted_certificates=neo4j.TrustSystemCAs() |
| 68 | + ) |
| 69 | + """ |
| 70 | + pass |
| 71 | + |
| 72 | + |
| 73 | +class TrustAll(TrustStore): |
| 74 | + """Used to configure the driver to trust all certificates. |
| 75 | +
|
| 76 | + Trust any server certificate. This ensures that communication |
| 77 | + is encrypted but does not verify the server certificate against a |
| 78 | + certificate authority. This option is primarily intended for use with |
| 79 | + the default auto-generated server certificate. |
| 80 | +
|
| 81 | +
|
| 82 | + For example:: |
| 83 | +
|
| 84 | + import neo4j |
| 85 | +
|
| 86 | + driver = neo4j.GraphDatabase.driver( |
| 87 | + url, auth=auth, trusted_certificates=neo4j.TrustAll() |
| 88 | + ) |
| 89 | + """ |
| 90 | + pass |
| 91 | + |
| 92 | + |
| 93 | +class TrustCustomCAs(TrustStore): |
| 94 | + """Used to configure the driver to trust custom CAs. |
| 95 | +
|
| 96 | + Trust server certificates that can be verified against the certificate |
| 97 | + authority at the specified paths. This option is primarily intended for |
| 98 | + self-signed and custom certificates. |
| 99 | +
|
| 100 | + :param certificates (str): paths to the certificates to trust. |
| 101 | + Those are not the certificates you expect to see from the server but |
| 102 | + the CA certificates you expect to be used to sign the server's |
| 103 | + certificate. |
| 104 | +
|
| 105 | + For example:: |
| 106 | +
|
| 107 | + import neo4j |
| 108 | +
|
| 109 | + driver = neo4j.GraphDatabase.driver( |
| 110 | + url, auth=auth, |
| 111 | + trusted_certificates=neo4j.TrustCustomCAs( |
| 112 | + "/path/to/ca1.crt", "/path/to/ca2.crt", |
| 113 | + ) |
| 114 | + ) |
| 115 | + """ |
| 116 | + def __init__(self, *certificates): |
| 117 | + self.certs = certificates |
| 118 | + |
| 119 | + |
55 | 120 | class DeprecatedAlias: |
56 | 121 | """Used when a config option has been renamed.""" |
57 | 122 |
|
|
0 commit comments