Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Mutual TLS authentication #702

Merged
merged 2 commits into from
Jul 11, 2019
Merged
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
16 changes: 16 additions & 0 deletions influxdb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ class InfluxDBClient(object):
:type proxies: dict
:param path: path of InfluxDB on the server to connect, defaults to ''
:type path: str
:param cert: Path to client certificate information to use for mutual TLS
authentication. You can specify a local cert to use
as a single file containing the private key and the certificate, or as
a tuple of both files’ paths, defaults to None
:type cert: str

:raises ValueError: if cert is provided but ssl is disabled (set to False)
"""

def __init__(self,
Expand All @@ -78,6 +85,7 @@ def __init__(self,
proxies=None,
pool_size=10,
path='',
cert=None,
):
"""Construct a new InfluxDBClient object."""
self.__host = host
Expand Down Expand Up @@ -120,6 +128,14 @@ def __init__(self,
else:
self._proxies = proxies

if cert:
if not ssl:
raise ValueError(
"Client certificate provided but ssl is disabled."
)
else:
self._session.cert = cert

self.__baseurl = "{0}://{1}:{2}{3}".format(
self._scheme,
self._host,
Expand Down
8 changes: 8 additions & 0 deletions influxdb/tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ def test_dsn(self):
**{'ssl': False})
self.assertEqual('http://my.host.fr:1886', cli._baseurl)

def test_cert(self):
"""Test mutual TLS authentication for TestInfluxDBClient object."""
cli = InfluxDBClient(ssl=True, cert='/etc/pki/tls/private/dummy.crt')
self.assertEqual(cli._session.cert, '/etc/pki/tls/private/dummy.crt')

with self.assertRaises(ValueError):
cli = InfluxDBClient(cert='/etc/pki/tls/private/dummy.crt')

def test_switch_database(self):
"""Test switch database in TestInfluxDBClient object."""
cli = InfluxDBClient('host', 8086, 'username', 'password', 'database')
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy