Allow disabling SSL certificates verification (#256)

Co-authored-by: cksac <cksac@gmail.com>
This commit is contained in:
cksac 2020-11-25 18:16:53 +08:00 committed by GitHub
parent 905dd24b09
commit 87340052a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -29,6 +29,7 @@ class S3BucketConfig(object):
acl = attrib(type=str, converter=_none_to_empty_string, default="")
secure = attrib(type=bool, default=True)
region = attrib(type=str, converter=_none_to_empty_string, default="")
verify = attrib(type=bool, default=True)
def update(self, key, secret, multipart=True, region=None):
self.key = key

View File

@ -9,7 +9,7 @@ class SetupUploadMixin(object):
storage_uri = abstractproperty()
def setup_upload(
self, bucket_name, host=None, access_key=None, secret_key=None, region=None, multipart=True, https=True):
self, bucket_name, host=None, access_key=None, secret_key=None, region=None, multipart=True, https=True, verify=True):
"""
Setup upload options (currently only S3 is supported)
@ -30,6 +30,8 @@ class SetupUploadMixin(object):
:type https: bool
:param region: Bucket region. Required if the bucket doesn't reside in the default region (us-east-1)
:type region: str
:param verify: Whether or not to verify SSL certificates. Only required when using a Non-AWS S3 solution that only supports HTTPS with self-signed certificate.
:type verify: bool
"""
self._bucket_config = S3BucketConfig(
bucket=bucket_name,
@ -38,7 +40,8 @@ class SetupUploadMixin(object):
secret=secret_key,
multipart=multipart,
secure=https,
region=region
region=region,
verify=verify
)
self.storage_uri = ('s3://%(host)s/%(bucket_name)s' if host else 's3://%(bucket_name)s') % locals()
StorageHelper.add_configuration(self._bucket_config, log=self.log)

View File

@ -1236,6 +1236,7 @@ class _Boto3Driver(_Driver):
aws_secret_access_key=cfg.secret,
endpoint_url=endpoint,
use_ssl=cfg.secure,
verify=cfg.verify,
config=botocore.client.Config(
max_pool_connections=max(
_Boto3Driver._min_pool_connections,