Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Hotfix boto3 now need ssl and verify to work in production #659

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APScheduler==3.10.0
boto3==1.26.79
botocore==1.29.79
botocore==1.29.138
cryptography==39.0.1
endesive==2.0.9
Flask_Caching==2.0.2
Expand Down
7 changes: 4 additions & 3 deletions app/utils/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(
secret_key,
access_key,
verify,
use_ssl,
cert,
private_key,
): # pylint: disable=too-many-arguments
Expand All @@ -40,6 +41,8 @@ def __init__(
self.secret_key = secret_key
assert isinstance(verify, (bool, Path))
self.verify = verify
assert isinstance(use_ssl, (bool, Path))
self.use_ssl = use_ssl
assert isinstance(cert, (Path, type(None)))
self.cert = cert
assert isinstance(private_key, (Path, type(None)))
Expand All @@ -49,11 +52,8 @@ def __init__(
"connect_timeout": 40,
}

use_ssl = False

if cert and private_key:
config_params["client_cert"] = (cert, private_key)
use_ssl = True

config = botocore.client.Config(**config_params)
self.s3_client = boto3.client(
Expand Down Expand Up @@ -148,6 +148,7 @@ def get_s3_client():
secret_key=settings.s3.secret_key,
access_key=settings.s3.access_key,
verify=settings.s3.verify,
use_ssl=settings.s3.use_ssl,
cert=settings.s3.cert,
private_key=settings.s3.private_key,
)
Expand Down
1 change: 1 addition & 0 deletions app/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
s3.secret_key = os.environ.get("S3_SECRETKEY", "secretkeytest")
s3.access_key = os.environ.get("S3_ACCESSKEY", "accesskeytest")
s3.verify = json.loads(os.environ.get("S3_VERIFY", "True").lower())
s3.use_ssl = json.loads(os.environ.get("S3_USESSL", "True").lower())
s3.cert = None
s3.private_key = None