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
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...