Skip to content

Commit

Permalink
bug when loading custom certificate too late - some http clients were…
Browse files Browse the repository at this point in the history
… initialized before it was loaded, caused ssl errors (#1485)
  • Loading branch information
arikalon1 authored Jul 3, 2024
1 parent aed9399 commit 0b63f9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ exclude = .git,
.mypy_cache,
src/robusta/integrations/kubernetes/autogenerated,
src/robusta/integrations/kubernetes/custom_models.py
ignore = E501, W503, E203
ignore = E501, W503, E203, E402
16 changes: 12 additions & 4 deletions src/robusta/runner/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import os

from robusta.runner.ssl_utils import add_custom_certificate

ADDITIONAL_CERTIFICATE: str = os.environ.get("CERTIFICATE", "")

if add_custom_certificate(ADDITIONAL_CERTIFICATE):
print("added custom certificate")

# DO NOT ADD ANY CODE ABOVE THIS
# ADDING IMPORTS BEFORE ADDING THE CUSTOM CERTS MIGHT INIT HTTP CLIENTS THAT DOESN'T RESPECT THE CUSTOM CERT

import signal

from robusta.core.model.env_vars import (
ADDITIONAL_CERTIFICATE,
ENABLE_TELEMETRY,
ROBUSTA_TELEMETRY_ENDPOINT,
SEND_ADDITIONAL_TELEMETRY,
Expand All @@ -13,7 +24,6 @@
from robusta.runner.config_loader import ConfigLoader
from robusta.runner.log_init import init_logging, logging
from robusta.runner.process_setup import process_setup
from robusta.runner.ssl_utils import add_custom_certificate
from robusta.runner.telemetry_service import TelemetryLevel, TelemetryService
from robusta.runner.web import Web
from robusta.utils.server_start import ServerStart
Expand All @@ -23,8 +33,6 @@ def main():
process_setup()
init_logging()
ServerStart.set()
if add_custom_certificate(ADDITIONAL_CERTIFICATE):
logging.info("added custom certificate")

create_monkey_patches()
registry = Registry()
Expand Down

0 comments on commit 0b63f9d

Please sign in to comment.