<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error) in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170684#M2290</link>
    <description>&lt;P&gt;Are you using a self-signed cert?  Keystore up to date?  &lt;/P&gt;</description>
    <pubDate>Tue, 23 Jun 2015 19:58:14 GMT</pubDate>
    <dc:creator>jnicholsenernoc</dc:creator>
    <dc:date>2015-06-23T19:58:14Z</dc:date>
    <item>
      <title>Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170676#M2282</link>
      <description>&lt;P&gt;New to Splunk &lt;EM&gt;and&lt;/EM&gt; Python... Trying to get up and running with the Python SDK. Installed the SDK for Python libraries, and modified the &lt;CODE&gt;splunk-sdk-python-master/examples/abc/a.py&lt;/CODE&gt; file with values that work to log in to our Enterprise installation via the web:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import httplib 
#etc

HOST = "54.xxx.xxx.xxx"
PORT = 8000
USERNAME = "my-username"
PASSWORD = "my-password"

#etc etc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I run this from the terminal with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;python a.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
File "/Users/ben/Desktop/splunk-sdk-python-master/examples/abc/a.py", line 38, in &amp;lt;module&amp;gt;
    connection.request("POST", "/services/auth/login", body, headers)
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 812, in send
    self.connect()
  File "/Users/ben/anaconda/lib/python2.7/httplib.py", line 1212, in connect
    server_hostname=server_hostname)
  File "/Users/ben/anaconda/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
  File "/Users/ben/anaconda/lib/python2.7/ssl.py", line 566, in __init__
    self.do_handshake()
  File "/Users/ben/anaconda/lib/python2.7/ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:581)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can anyone suggest what I might be doing wrong? Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 14:58:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170676#M2282</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-23T14:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170677#M2283</link>
      <description>&lt;P&gt;Can you please copy some code from a.py file, specially some code around line 38 (few lines above and below).&lt;/P&gt;

&lt;P&gt;File "/Users/ben/Desktop/splunk-sdk-python-master/examples/abc/a.py", line 38, in &lt;BR /&gt;
     connection.request("POST", "/services/auth/login", body, headers)&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 15:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170677#M2283</guid>
      <dc:creator>vinitatsky</dc:creator>
      <dc:date>2015-06-23T15:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170678#M2284</link>
      <description>&lt;P&gt;The rest of the file is as downloaded from the SDK for Splunk. Here's the file in its entirety,  as used, except for the server/login credentials:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;# Copyright 2011-2014 Splunk, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     &lt;A href="http://www.apache.org/licenses/LICENSE-2.0" target="test_blank"&gt;http://www.apache.org/licenses/LICENSE-2.0&lt;/A&gt;
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""Retrieves a list of installed apps from Splunk by making REST API calls
   using Python's httplib module."""

import httplib
import urllib
from xml.etree import ElementTree

HOST = "54.xxx.xxx.xxx"
PORT = 8000
USERNAME = "my-username"
PASSWORD = "my-password"

# Present credentials to Splunk and retrieve the session key
connection = httplib.HTTPSConnection(HOST, PORT)
body = urllib.urlencode({'username': USERNAME, 'password': PASSWORD})
headers = { 
    'Content-Type': "application/x-www-form-urlencoded", 
    'Content-Length': str(len(body)),
    'Host': HOST,
    'User-Agent': "a.py/1.0",
    'Accept': "*/*"
}
try:
    connection.request("POST", "/services/auth/login", body, headers)
    response = connection.getresponse()
finally:
    connection.close()
if response.status != 200:
    raise Exception, "%d (%s)" % (response.status, response.reason)
body = response.read()
sessionKey = ElementTree.XML(body).findtext("./sessionKey")

# Now make the request to Splunk for list of installed apps
connection = httplib.HTTPSConnection(HOST, PORT)
headers = { 
    'Content-Length': "0",
    'Host': HOST,
    'User-Agent': "a.py/1.0",
    'Accept': "*/*",
    'Authorization': "Splunk %s" % sessionKey,
}
try:
    connection.request("GET", "/services/apps/local", "", headers)
    response = connection.getresponse()
finally:
    connection.close()
if response.status != 200:
    raise Exception, "%d (%s)" % (response.status, response.reason)

body = response.read()
data = ElementTree.XML(body)
apps = data.findall("{http://www.w3.org/2005/Atom}entry/{http://www.w3.org/2005/Atom}title")
for app in apps: 
    print app.text
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2015 16:56:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170678#M2284</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-23T16:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170679#M2285</link>
      <description>&lt;P&gt;Make sure you are using the right port for your instance.  &lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 16:59:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170679#M2285</guid>
      <dc:creator>jnicholsenernoc</dc:creator>
      <dc:date>2015-06-23T16:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170680#M2286</link>
      <description>&lt;P&gt;Ah, OK. The port 8000 works for accessing the instance through the web interface. Should I use a different port for access via the Python SDK?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:03:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170680#M2286</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-23T17:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170681#M2287</link>
      <description>&lt;P&gt;Can you try 8089&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:04:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170681#M2287</guid>
      <dc:creator>vinitatsky</dc:creator>
      <dc:date>2015-06-23T17:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170682#M2288</link>
      <description>&lt;P&gt;Should be the Splunk management port, 8089&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEFC"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEFC&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:08:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170682#M2288</guid>
      <dc:creator>jnicholsenernoc</dc:creator>
      <dc:date>2015-06-23T17:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170683#M2289</link>
      <description>&lt;P&gt;OK, I tried port 8089—it still fails at line 38, but the error message is now:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:09:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170683#M2289</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-23T17:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170684#M2290</link>
      <description>&lt;P&gt;Are you using a self-signed cert?  Keystore up to date?  &lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170684#M2290</guid>
      <dc:creator>jnicholsenernoc</dc:creator>
      <dc:date>2015-06-23T19:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170685#M2291</link>
      <description>&lt;P&gt;I don't know—let me find out. Thank you for the suggestion!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2015 20:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170685#M2291</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-23T20:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170686#M2292</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;PORT = 8000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That is the wrong port.&lt;BR /&gt;
The SplunkD Management port is 8089 by default (as per what is actually in the a.py example).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;PORT = 8089
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jun 2015 01:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170686#M2292</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2015-06-24T01:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170687#M2293</link>
      <description>&lt;P&gt;OK, folks—I think I figured a few things out here. Thank you to all of you who suggested using port 8089 instead of 8000. That was certainly part of the problem.&lt;/P&gt;

&lt;P&gt;The two other problems I've identified are:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;The ABC examples, at least (I don't know about the rest of the python SDK), don't seem to work under Python v2.7.10. When I tried running the &lt;CODE&gt;c.py&lt;/CODE&gt; example (with port 8089) under Python v2.7.8, I was able to get it to work—it connects and returns the list of installed apps as expected.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;The &lt;CODE&gt;a.py&lt;/CODE&gt; example, however, seems to have another problem. With the same login credentials, port, and in the same environment, it returns this error:&lt;/P&gt;

&lt;P&gt;(splunksnake)Bens-MacBook-Pro-2:~ ben$ python /Users/ben/Desktop/splunk-sdk-python-master\ 2/examples/abc/a.py &lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "/Users/ben/Desktop/splunk-sdk-python-master 2/examples/abc/a.py", line 45, in &lt;MODULE&gt;&lt;BR /&gt;
    sessionKey = ElementTree.XML(body).findtext("./sessionKey")&lt;BR /&gt;
  File "/Users/ben/anaconda/envs/splunksnake/lib/python2.7/xml/etree/ElementTree.py", line 1301, in XML&lt;BR /&gt;
    return parser.close()&lt;BR /&gt;
  File "/Users/ben/anaconda/envs/splunksnake/lib/python2.7/xml/etree/ElementTree.py", line 1654, in close&lt;BR /&gt;
    self._raiseerror(v)&lt;BR /&gt;
  File "/Users/ben/anaconda/envs/splunksnake/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror&lt;BR /&gt;
    raise err&lt;BR /&gt;
xml.etree.ElementTree.ParseError: no element found: line 1, column 0&lt;/MODULE&gt;&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Using &lt;CODE&gt;curl&lt;/CODE&gt; from the terminal, I can see the Splunk instance is returning a sessionKey, so perhaps there is an issue with the way that key is being handled. &lt;/P&gt;

&lt;P&gt;Anyway, thanks again for your help sorting this out! &lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2015 16:27:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170687#M2293</guid>
      <dc:creator>benridescout</dc:creator>
      <dc:date>2015-06-24T16:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK ABC example — not working (SSL: UNKNOWN_PROTOCOL error)</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170688#M2294</link>
      <description>&lt;P&gt;I'm getting exactly the same issue. From 2.7.10 not working, downgraded to 2.7.6, to a.py not working and c.py working. Ports and credentials checked.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2015 08:26:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-ABC-example-not-working-SSL-UNKNOWN-PROTOCOL-error/m-p/170688#M2294</guid>
      <dc:creator>dformoso</dc:creator>
      <dc:date>2015-07-15T08:26:09Z</dc:date>
    </item>
  </channel>
</rss>

