Skip to content

Commit af40f19

Browse files
committed
Fix handling of self-signed certs in s3_conn
Take insecure/verify/cacert parameter from clouds.yaml and pass it to boto3.resource. If insecure is True or verify is False use verify=False also for boto3. Else, if you provide cacert(via cacert or verify parameter) it is also used for boto3. If nothing from above is met, use verify=None to keep default boto3 behaviour. Signed-off-by: Roman Hros <roman.hros@dnation.cloud>
1 parent b9fcb78 commit af40f19

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Tests/iaas/scs_0123_mandatory_services/mandatory_services.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ def compute_scs_0123_service_presence(services_lookup, *names):
2828

2929
def s3_conn(creds, conn):
3030
"""Return an s3 client conn"""
31+
insecure = conn.config.config.get("insecure")
32+
verify = conn.config.config.get("verify")
3133
cacert = conn.config.config.get("cacert")
32-
# TODO: Handle self-signed certs (from ca_cert in openstack config)
33-
if cacert:
34-
logger.warning(f"Trust all Certificates in S3, OpenStack uses {cacert}")
34+
vrfy = False if (insecure is True or verify is False) else \
35+
(cacert or (verify if isinstance(verify, str) else None))
3536
return boto3.resource(
36-
's3', endpoint_url=creds["HOST"], verify=not cacert,
37+
's3', endpoint_url=creds["HOST"], verify=vrfy,
3738
aws_access_key_id=creds["AK"], aws_secret_access_key=creds["SK"],
3839
)
3940

0 commit comments

Comments
 (0)