Skip to content

Commit c16b27f

Browse files
authored
Merge pull request #43 from elimity-com/bugfix/42-verify-ssl
Support disabling SSL verification
2 parents 07ecc97 + 5ef517a commit c16b27f

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

elimity_insights_client.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,20 @@ def reload_domain_graph(self, graph: "DomainGraph") -> None:
8181
body = _encode_domain_graph(graph)
8282
self._post(body, "domain-graph/reload")
8383

84-
@property
85-
def _cert(self) -> Optional[Tuple[str, str]]:
86-
certificate = self._config.certificate
87-
if certificate is None:
88-
return None
89-
else:
90-
return certificate.certificate_path, certificate.private_key_path
91-
9284
def _post(self, body: Any, path: str) -> None:
9385
data = _encode(body)
94-
url = f"{self._config.base_path}/{path}"
95-
authorization = f"Bearer {self._config.token}"
86+
config = self._config
87+
url = f"{config.base_path}/{path}"
88+
cert = _cert(config.certificate)
89+
authorization = f"Bearer {config.token}"
9690
headers = {
9791
"Authorization": authorization,
9892
"Content-Encoding": "deflate",
9993
"Content-Type": "application/json",
10094
}
101-
response = post(url, cert=self._cert, data=data, headers=headers)
95+
response = post(
96+
url, cert=cert, data=data, headers=headers, verify=config.verify_ssl
97+
)
10298
response.raise_for_status()
10399

104100

@@ -221,6 +217,13 @@ class Type(Enum):
221217
]
222218

223219

220+
def _cert(certificate: Certificate) -> Optional[Tuple[str, str]]:
221+
if certificate is None:
222+
return None
223+
else:
224+
return certificate.certificate_path, certificate.private_key_path
225+
226+
224227
def _compress(chunks: Iterable[bytes]) -> Iterable[bytes]:
225228
compress = compressobj()
226229
for chunk in chunks:

0 commit comments

Comments
 (0)