thefactory/marathon-python

SSE SSL authentication not supported

Closed this issue · 2 comments

client.py:_do_sse_request() does not respect the self.verify setting, and does not provide any way to authentication based on credentials (verify or cert).

The following code fails with: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

from marathon import MarathonClient
import logging

c = MarathonClient('https://localhost:8080', verify=False)
for event in c.event_stream(raw=True):
    print(event)

Assuming that Marathon runs on localhost:8080 with SSL and no user authentication.

Here is how to do it (use sse_session=):

import marathon
import requests
import os

session = requests.Session()
session.verify = False

c = marathon.MarathonClient(
    'https://marathon-pa4.central.criteo.preprod/',
    verify=False,
    sse_session=session,
    username=os.getenv('MARATHON_USERNAME'),
    password=os.getenv('MARATHON_PASSWORD'),
)

for event in c.event_stream(raw=True):
    print(event)

Thanks for the a workaround!

Still, I would expect the library to enforce verify=False, since MarathonClient() accepts it as an argument.