Skip to content

Commit 66525fc

Browse files
author
Felix Fanghaenel
committed
issue PyFilesystem#39: pass use_ssl, verify arguments to boto3 client constructor
implementation slightly changed based on old discussion in PyFilesystem#40
1 parent 7f95af6 commit 66525fc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

fs_s3fs/_s3fs.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ class S3FS(FS):
214214
PyFilesystem specification exactly. Set to ``False`` to disable
215215
validation of destination paths which may speed up uploads /
216216
downloads.
217+
:param bool use_ssl: Whether or not to use SSL. The default is ``True``.
218+
:param bool or str verify: Whether or not to verify SSL certificates. By
219+
default SSL certificates are verified. Set to ``False`` to disable
220+
verification of SSL certificates. To use a different CA cert bundle
221+
than the one used by botocore, set this parameter to a string that is
222+
the path to a CA cert bundle. The default is ``None``, which inherits
223+
the default behavior of botocore.
217224
:param str cache_control: Sets the 'Cache-Control' header for uploads.
218225
:param str acl: Sets the Access Control List header for uploads.
219226
:param dict upload_args: A dictionary for additional upload arguments.
@@ -273,6 +280,8 @@ def __init__(
273280
region=None,
274281
delimiter="/",
275282
strict=True,
283+
use_ssl=True,
284+
verify=None,
276285
cache_control=None,
277286
acl=None,
278287
upload_args=None,
@@ -294,6 +303,8 @@ def __init__(
294303
self.region = region
295304
self.delimiter = delimiter
296305
self.strict = strict
306+
self.use_ssl = use_ssl
307+
self.verify = verify
297308
self._tlocal = threading.local()
298309
if cache_control or acl:
299310
upload_args = upload_args or {}
@@ -371,6 +382,8 @@ def s3(self):
371382
aws_secret_access_key=self.aws_secret_access_key,
372383
aws_session_token=self.aws_session_token,
373384
endpoint_url=self.endpoint_url,
385+
use_ssl=self.use_ssl,
386+
verify=self.verify,
374387
)
375388
return self._tlocal.s3
376389

@@ -384,6 +397,8 @@ def client(self):
384397
aws_secret_access_key=self.aws_secret_access_key,
385398
aws_session_token=self.aws_session_token,
386399
endpoint_url=self.endpoint_url,
400+
use_ssl=self.use_ssl,
401+
verify=self.verify,
387402
)
388403
return self._tlocal.client
389404

fs_s3fs/opener.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ def open_fs(self, fs_url, parse_result, writeable, create, cwd):
2525
if "strict" in parse_result.params
2626
else True
2727
)
28+
use_ssl = (
29+
parse_result.params['use_ssl'] == '1'
30+
if 'use_ssl' in parse_result.params
31+
else True
32+
)
33+
verify = parse_result.params.get('verify', None)
34+
if verify == '0':
35+
verify = False
2836
s3fs = S3FS(
2937
bucket_name,
3038
dir_path=dir_path or "/",
@@ -34,5 +42,7 @@ def open_fs(self, fs_url, parse_result, writeable, create, cwd):
3442
acl=parse_result.params.get("acl", None),
3543
cache_control=parse_result.params.get("cache_control", None),
3644
strict=strict,
45+
use_ssl=use_ssl,
46+
verify=verify,
3747
)
3848
return s3fs

0 commit comments

Comments
 (0)