Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23d636f

Browse files
authoredAug 15, 2023
Merge pull request #82 from janjagusch/s3-disable-ssl-verification
Add option to disable SSL verification for S3Store
2 parents df0e1d3 + 7b40a87 commit 23d636f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎docs/changes.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
1.8.0
55
=====
66
* Fixed the behaviour of ``S3FSStore`` when providing a custom endpoint.
7+
* Added ``verify`` constructor argument to ``S3FSStore`` that disables SSL verification. Use it in an URI as ``?verify=false``.
78

89
1.7.0
910
=====

‎minimalkv/net/s3fsstore.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(
3232
reduced_redundancy=False,
3333
public=False,
3434
metadata=None,
35+
verify=True,
3536
):
3637
if isinstance(bucket, str):
3738
import boto3
@@ -47,6 +48,7 @@ def __init__(
4748
self.reduced_redundancy = reduced_redundancy
4849
self.public = public
4950
self.metadata = metadata or {}
51+
self.verify = verify
5052

5153
# Get endpoint URL
5254
self.endpoint_url = self.bucket.meta.client.meta.endpoint_url
@@ -66,7 +68,7 @@ def _create_filesystem(self) -> "S3FileSystem":
6668
if not has_s3fs:
6769
raise ImportError("Cannot find optional dependency s3fs.")
6870

69-
client_kwargs = {}
71+
client_kwargs = {"verify": self.verify}
7072
if self.endpoint_url:
7173
client_kwargs["endpoint_url"] = self.endpoint_url
7274

@@ -187,4 +189,6 @@ def _from_parsed_url(
187189
# The bucket will be created in the `create_filesystem` method if it doesn't exist.
188190
bucket = resource.Bucket(bucket_name)
189191

190-
return cls(bucket)
192+
verify = query.get("verify", "true").lower() == "true"
193+
194+
return cls(bucket, verify=verify)

‎tests/store_creation/test_creation_boto3store.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
storage = pytest.importorskip("google.cloud.storage")
99

10-
S3_URL = "s3://minio:miniostorage@127.0.0.1:9000/bucketname?create_if_missing=true&is_secure=false"
10+
S3_URL = "s3://minio:miniostorage@127.0.0.1:9000/bucketname?create_if_missing=true&is_secure=false&verify=false"
1111

1212
"""
1313
When using the `s3` scheme in a URL, the new store creation returns an `S3FSStore`.
@@ -26,6 +26,7 @@ def test_new_s3fs_creation():
2626
bucket_name="bucketname-minio",
2727
is_secure=False,
2828
),
29+
verify=False,
2930
)
3031

3132
actual = get_store_from_url(S3_URL)

0 commit comments

Comments
 (0)
Please sign in to comment.