@@ -33,6 +33,7 @@ def __init__(self, url, token, debug=None, timeout=10000, enable_gzip=False, org
33
33
supports the Gzip compression.
34
34
:param org: organization name (used as a default in query and write API)
35
35
:key bool verify_ssl: Set this to false to skip verifying SSL certificate when calling API from https server.
36
+ :key str ssl_ca_cert: Set this to customize the certificate file to verify the peer.
36
37
:key urllib3.util.retry.Retry retries: Set the default retry strategy that is used for all HTTP requests
37
38
except batching writes. As a default there is no one retry strategy.
38
39
@@ -52,6 +53,7 @@ def __init__(self, url, token, debug=None, timeout=10000, enable_gzip=False, org
52
53
conf .enable_gzip = enable_gzip
53
54
conf .debug = debug
54
55
conf .verify_ssl = kwargs .get ('verify_ssl' , True )
56
+ conf .ssl_ca_cert = kwargs .get ('ssl_ca_cert' , None )
55
57
56
58
auth_token = self .token
57
59
auth_header_name = "Authorization"
@@ -73,6 +75,7 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz
73
75
- token
74
76
- timeout,
75
77
- verify_ssl
78
+ - ssl_ca_cert
76
79
"""
77
80
config = configparser .ConfigParser ()
78
81
config .read (config_file )
@@ -94,17 +97,21 @@ def from_config_file(cls, config_file: str = "config.ini", debug=None, enable_gz
94
97
if config .has_option ('influx2' , 'verify_ssl' ):
95
98
verify_ssl = config ['influx2' ]['verify_ssl' ]
96
99
100
+ ssl_ca_cert = None
101
+ if config .has_option ('influx2' , 'ssl_ca_cert' ):
102
+ ssl_ca_cert = config ['influx2' ]['ssl_ca_cert' ]
103
+
97
104
default_tags = None
98
105
99
106
if config .has_section ('tags' ):
100
107
default_tags = dict (config .items ('tags' ))
101
108
102
109
if timeout :
103
110
return cls (url , token , debug = debug , timeout = int (timeout ), org = org , default_tags = default_tags ,
104
- enable_gzip = enable_gzip , verify_ssl = _to_bool (verify_ssl ))
111
+ enable_gzip = enable_gzip , verify_ssl = _to_bool (verify_ssl ), ssl_ca_cert = ssl_ca_cert )
105
112
106
113
return cls (url , token , debug = debug , org = org , default_tags = default_tags , enable_gzip = enable_gzip ,
107
- verify_ssl = _to_bool (verify_ssl ))
114
+ verify_ssl = _to_bool (verify_ssl ), ssl_ca_cert = ssl_ca_cert )
108
115
109
116
@classmethod
110
117
def from_env_properties (cls , debug = None , enable_gzip = False ):
@@ -117,12 +124,14 @@ def from_env_properties(cls, debug=None, enable_gzip=False):
117
124
- INFLUXDB_V2_TOKEN
118
125
- INFLUXDB_V2_TIMEOUT
119
126
- INFLUXDB_V2_VERIFY_SSL
127
+ - INFLUXDB_V2_SSL_CA_CERT
120
128
"""
121
129
url = os .getenv ('INFLUXDB_V2_URL' , "http://localhost:8086" )
122
130
token = os .getenv ('INFLUXDB_V2_TOKEN' , "my-token" )
123
131
timeout = os .getenv ('INFLUXDB_V2_TIMEOUT' , "10000" )
124
132
org = os .getenv ('INFLUXDB_V2_ORG' , "my-org" )
125
133
verify_ssl = os .getenv ('INFLUXDB_V2_VERIFY_SSL' , "True" )
134
+ ssl_ca_cert = os .getenv ('INFLUXDB_V2_SSL_CA_CERT' , None )
126
135
127
136
default_tags = dict ()
128
137
@@ -131,7 +140,7 @@ def from_env_properties(cls, debug=None, enable_gzip=False):
131
140
default_tags [key [16 :].lower ()] = value
132
141
133
142
return cls (url , token , debug = debug , timeout = int (timeout ), org = org , default_tags = default_tags ,
134
- enable_gzip = enable_gzip , verify_ssl = _to_bool (verify_ssl ))
143
+ enable_gzip = enable_gzip , verify_ssl = _to_bool (verify_ssl ), ssl_ca_cert = ssl_ca_cert )
135
144
136
145
def write_api (self , write_options = WriteOptions (), point_settings = PointSettings ()) -> WriteApi :
137
146
"""
0 commit comments