splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
698 stars 370 forks source link

mTLS support #362

Closed RaviTezu closed 3 years ago

RaviTezu commented 3 years ago

Hi, Our Splunk instance uses mTLS and then username/password to authenticate clients. Any example that you can provide? I can use splunklib.client.connect for basic auth but looks like it doesn't take the client side certificate paths ? Thank you.

RaviTezu commented 3 years ago

Found a way, you can pass on a custom handler(which accepts the client certs) to the splunklib.client.connect.

import splunklib.client as client
from splunklib.binding import handler
. 
.
.
        connection = client.connect(
            **{
                "host": <splunk-url>,
                "scheme": <scheme(https)>,
                "port": <splunk-port>,
                "autologin": True,
                "username": <username>,
                "password": <password>,
                "handler": handler(cert_file=<path-to-cert-file>, key_file=<path-to-private-key-file>, verify=True)
            }