|
23 | 23 |
|
24 | 24 | import boto3 |
25 | 25 | import jwt |
26 | | -import urllib3 |
| 26 | +from botocore.exceptions import BotoCoreError, NoCredentialsError |
27 | 27 | from jsonschema import validate |
28 | 28 | from jsonschema.exceptions import ValidationError |
29 | 29 |
|
30 | 30 | from src.handlers.handler_token import HandlerToken |
| 31 | +from src.utils.constants import SSL_CA_BUNDLE_KEY |
31 | 32 | from src.writers import writer_eventbridge, writer_kafka, writer_postgres |
32 | 33 | from src.utils.conf_path import CONF_DIR, INVALID_CONF_ENV |
33 | 34 |
|
34 | 35 | # Internal aliases used by rest of module |
35 | 36 | _CONF_DIR = CONF_DIR |
36 | 37 | _INVALID_CONF_ENV = INVALID_CONF_ENV |
37 | 38 |
|
38 | | -urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
39 | 39 |
|
40 | 40 | logger = logging.getLogger(__name__) |
41 | 41 | log_level = os.environ.get("LOG_LEVEL", "INFO") |
|
64 | 64 | config = json.load(file) |
65 | 65 | logger.debug("Loaded main CONFIG") |
66 | 66 |
|
67 | | -aws_s3 = boto3.Session().resource("s3", verify=False) # nosec Boto verify disabled intentionally |
68 | | -logger.debug("Initialized AWS S3 Client") |
| 67 | +# Initialize S3 client with SSL verification |
| 68 | +try: |
| 69 | + ssl_verify = config.get(SSL_CA_BUNDLE_KEY, True) |
| 70 | + aws_s3 = boto3.Session().resource("s3", verify=ssl_verify) |
| 71 | + logger.debug("Initialized AWS S3 Client") |
| 72 | +except (BotoCoreError, NoCredentialsError) as exc: |
| 73 | + logger.exception("Failed to initialize AWS S3 client") |
| 74 | + raise RuntimeError("AWS S3 client initialization failed") from exc |
69 | 75 |
|
70 | 76 | if config["access_config"].startswith("s3://"): |
71 | 77 | name_parts = config["access_config"].split("/") |
|
0 commit comments