From c3a61ad9cf126169749bba116a7349fae81fbb7c Mon Sep 17 00:00:00 2001 From: NigelVanHattum Date: Wed, 31 Mar 2021 22:31:38 +0200 Subject: [PATCH] Added SSL verification option (#5732) * Added SSL verification option * Changed param name to avoid conflicts * verify_ssl now accepts strings * Added simple unit tests * Changed parameter name fron verify_ssl to ssl_verify so it's consistent with HTTP remotes Forget to change 1 test * add processing on ssl_verify param typo * revert back to bool param * Update dvc/config_schema.py Co-authored-by: Nigel Co-authored-by: Nigel Co-authored-by: Ruslan Kuprieiev --- dvc/config_schema.py | 1 + dvc/fs/s3.py | 2 ++ tests/unit/fs/test_s3.py | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/dvc/config_schema.py b/dvc/config_schema.py index 84ee1a120..41e9d4efb 100644 --- a/dvc/config_schema.py +++ b/dvc/config_schema.py @@ -145,6 +145,7 @@ SCHEMA = { "session_token": str, Optional("listobjects", default=False): Bool, # obsoleted Optional("use_ssl", default=True): Bool, + Optional("ssl_verify", default=True): Bool, "sse": str, "sse_kms_key_id": str, "acl": str, diff --git a/dvc/fs/s3.py b/dvc/fs/s3.py index 17176058a..f201ffeb5 100644 --- a/dvc/fs/s3.py +++ b/dvc/fs/s3.py @@ -38,6 +38,7 @@ class S3FileSystem(BaseFileSystem): self.endpoint_url = config.get("endpointurl") self.use_ssl = config.get("use_ssl", True) + self.ssl_verify = config.get("ssl_verify", True) self.extra_args = {} @@ -136,6 +137,7 @@ class S3FileSystem(BaseFileSystem): return session.resource( "s3", endpoint_url=self.endpoint_url, + verify=self.ssl_verify, use_ssl=self.use_ssl, config=boto3.session.Config( signature_version="s3v4", s3=s3_config diff --git a/tests/unit/fs/test_s3.py b/tests/unit/fs/test_s3.py index 568534233..030de7a02 100644 --- a/tests/unit/fs/test_s3.py +++ b/tests/unit/fs/test_s3.py @@ -29,6 +29,22 @@ def test_init(dvc): assert fs.path_info == url +def test_verify_ssl_default_param(dvc): + config = { + "url": url, + } + fs = S3FileSystem(dvc, config) + + assert fs.ssl_verify + + +def test_ssl_verify_bool_param(dvc): + config = {"url": url, "ssl_verify": False} + fs = S3FileSystem(dvc, config) + + assert fs.ssl_verify == config["ssl_verify"] + + def test_grants(dvc): config = { "url": url,