Splunk Dev

How can I troubleshoot a socket connection error from python to Splunk? (SSL: CERTIFICATE_VERIFY_FAILED)

manus
Communicator

I'm doing my first python script connecting to Splunk. It fails with following error:

Traceback (most recent call last):  
  File "PrintInterntalIndexEventCount.py", line 14, in <module>  
    password=PASSWORD,scheme=scheme)  
  File "C:\Python27\lib\site-packages\splunklib\client.py", line 305, in connect  
    return Service(**kwargs).login()   
  File "C:\Python27\lib\site-packages\splunklib\binding.py", line 761, in login   
    password=self.password)   
  File "C:\Python27\lib\site-packages\splunklib\binding.py", line 1090, in post  
    return self.request(url, message)   
  File "C:\Python27\lib\site-packages\splunklib\binding.py", line 1107, in request
    response = self.handler(url, message, **kwargs)
  File "C:\Python27\lib\site-packages\splunklib\binding.py", line 1225, in request
    connection.request(method, path, body, head)
  File "C:\Python27\lib\httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "C:\Python27\lib\httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "C:\Python27\lib\httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 850, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 812, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1216, in connect
    server_hostname=server_hostname)
  File "C:\Python27\lib\ssl.py", line 350, in wrap_socket
    _context=self)
  File "C:\Python27\lib\ssl.py", line 566, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

Here is the script

import splunklib.client as client

HOST = "lonsl1101443.uk.net.intra"
PORT = 8089
USERNAME = "user"
PASSWORD = "pwd"
scheme="https"

service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD,scheme=scheme)

for app in service.apps:
    print app.name  

If someone has the slightest idea about why this could fail, that would help!

Tags (4)
0 Karma
1 Solution

manus
Communicator

The problem was my python version install.
It doesn't work with: Python 2.7.9 64bit and Python 2.7.9 32bit.
It works with 2.7.8 32 Bit

View solution in original post

sylim_splunk
Splunk Employee
Splunk Employee

The proxy in our network is failing to verify the host certificate and hence not able to establish handshake.
After bypassing the host verification on the proxy we were able to connect to AWS endpoints.

0 Karma

manus
Communicator

The problem was my python version install.
It doesn't work with: Python 2.7.9 64bit and Python 2.7.9 32bit.
It works with 2.7.8 32 Bit

lasnow
Explorer

Thank you, that was driving me crazy!

0 Karma

etz
Engager

Thank you! Good to know.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Self-Healing Pipeline Is Now Generally Available: AI-Powered CIM Compliance

Maintaining data integrity across security and analytics pipelines is an ongoing challenge. Data ...

[Puzzles] Solve, Learn, Repeat: Family Trees

This puzzle (first published here is based on finding grandparents and grandchildren (inspired by a question ...

Break the Build: Inside the KubeDoom Lounge at .conf26

    You step up to the machine. The pixelated corridors of a certain 1993 FPS load in front of you, EMP Pulse ...