20
20
)
21
21
from arango .version import version
22
22
23
-
24
23
class ArangoClient :
25
24
"""ArangoDB client.
26
25
@@ -45,6 +44,8 @@ class ArangoClient:
45
44
the de-serialized object. If not given, ``json.loads`` is used by
46
45
default.
47
46
:type deserializer: callable
47
+ :param verify_certificate: Verify TLS certificates.
48
+ :type verify_certificate: bool
48
49
"""
49
50
50
51
def __init__ (
@@ -55,6 +56,7 @@ def __init__(
55
56
http_client : Optional [HTTPClient ] = None ,
56
57
serializer : Callable [..., str ] = lambda x : dumps (x ),
57
58
deserializer : Callable [[str ], Any ] = lambda x : loads (x ),
59
+ verify_certificate : bool = True ,
58
60
) -> None :
59
61
if isinstance (hosts , str ):
60
62
self ._hosts = [host .strip ("/" ) for host in hosts .split ("," )]
@@ -75,6 +77,10 @@ def __init__(
75
77
self ._serializer = serializer
76
78
self ._deserializer = deserializer
77
79
self ._sessions = [self ._http .create_session (h ) for h in self ._hosts ]
80
+
81
+ # set flag for SSL/TLS certificate verification
82
+ for session in self ._sessions :
83
+ session .verify = verify_certificate
78
84
79
85
def __repr__ (self ) -> str :
80
86
return f"<ArangoClient { ',' .join (self ._hosts )} >"
@@ -110,6 +116,7 @@ def db(
110
116
verify : bool = False ,
111
117
auth_method : str = "basic" ,
112
118
superuser_token : Optional [str ] = None ,
119
+ verify_certificate : bool = True ,
113
120
) -> StandardDatabase :
114
121
"""Connect to an ArangoDB database and return the database API wrapper.
115
122
@@ -130,6 +137,8 @@ def db(
130
137
If set, parameters **username**, **password** and **auth_method**
131
138
are ignored. This token is not refreshed automatically.
132
139
:type superuser_token: str
140
+ :param verify_certificate: Verify TLS certificates.
141
+ :type verify_certificate: bool
133
142
:return: Standard database API wrapper.
134
143
:rtype: arango.database.StandardDatabase
135
144
:raise arango.exceptions.ServerConnectionError: If **verify** was set
0 commit comments