Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Enable toggling ssl verification #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aioarango/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
http_client: Optional[HTTPClient] = None,
serializer: Callable[..., str] = lambda x: dumps(x),
deserializer: Callable[[str], Any] = lambda x: loads(x),
verify_ssl: bool = True,
) -> None:
if isinstance(hosts, str):
self._hosts = [host.strip("/") for host in hosts.split(",")]
Expand All @@ -68,7 +69,7 @@ def __init__(
self._http = http_client or DefaultHTTPClient()
self._serializer = serializer
self._deserializer = deserializer
self._sessions = [self._http.create_session(h) for h in self._hosts]
self._sessions = [self._http.create_session(h, verify_ssl) for h in self._hosts]

def __repr__(self) -> str:
return f"<ArangoClient {','.join(self._hosts)}>"
Expand Down
4 changes: 2 additions & 2 deletions aioarango/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ class DefaultHTTPClient(HTTPClient):
REQUEST_TIMEOUT = 60
RETRY_ATTEMPTS = 3

def create_session(self, host: str) -> httpx.AsyncClient:
def create_session(self, host: str, verify: bool = True) -> httpx.AsyncClient:
"""Create and return a new session/connection.

:param host: ArangoDB host URL.
:type host: str | unicode
:returns: httpx client object
:rtype: httpx.AsyncClient
"""
transport = httpx.AsyncHTTPTransport(retries=self.RETRY_ATTEMPTS)
transport = httpx.AsyncHTTPTransport(retries=self.RETRY_ATTEMPTS, verify=verify)
return httpx.AsyncClient(transport=transport)

async def send_request(
Expand Down