jssimporter / Spruce

Spruce is deprecated. Please see the wiki for alternatives.
GNU General Public License v3.0
148 stars 22 forks source link

SSL: WRONG_VERSION_NUMBER #34

Closed ddcdennisb closed 5 years ago

ddcdennisb commented 5 years ago

I ran this a while back and had no issues.

For the life of my i can't figure out what is happening. Anytime I try and run this script i get the following:

🌲 Building: Computer Groups Report... 🌲 Traceback (most recent call last): File "/Users/dennis/Desktop/spruce.py", line 2001, in main() File "/Users/dennis/Desktop/spruce.py", line 1997, in main run_reports(args) File "/Users/dennis/Desktop/spruce.py", line 1792, in run_reports results.append(func(args_dict)) File "/Users/dennis/Desktop/spruce.py", line 901, in build_computer_groups_report group_list = jss_connection.ComputerGroup() File "/Library/Python/2.7/site-packages/jss/jamf_software_server.py", line 566, in ComputerGroup return self.factory.get_object(jssobjects.ComputerGroup, data) File "/Library/Python/2.7/site-packages/jss/jamf_software_server.py", line 875, in get_object return self.get_list(obj_class, data, subset) File "/Library/Python/2.7/site-packages/jss/jamf_software_server.py", line 901, in get_list result = self.jss.get(url) File "/Library/Python/2.7/site-packages/jss/jamf_software_server.py", line 200, in get response = self.session.get(request_url) File "/Library/Python/2.7/site-packages/requests/sessions.py", line 525, in get return self.request('GET', url, kwargs) File "/Library/Python/2.7/site-packages/requests/sessions.py", line 512, in request resp = self.send(prep, send_kwargs) File "/Library/Python/2.7/site-packages/requests/sessions.py", line 622, in send r = adapter.send(request, kwargs) File "/Library/Python/2.7/site-packages/requests/adapters.py", line 511, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='casper.mycompany.com', port=8443): Max retries exceeded with url: /JSSResource/computergroups (Caused by SSLError(SSLError(1, u'[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:590)'),))

ehemmete commented 5 years ago

I have this same issue with the exact same (except URL) error messages. I've checked the python-jss version (1.5.0) and no update seems to be available. I did recently upgrade to JAMF Pro 10.7.1. I wonder if it could be on the server end?

aarondavidpolley commented 5 years ago

I also have this issue and found the fix:

The issue is in the Python JSS adaptor file. Jamf have hard coded TLSv1.2 for the most secure connection in your tomcat server server.xml file in the latest versions (which you can change if you choose).

Python JSS (and subsequently spruce) is set to TLS1 which inherently limits it to TLS1.0

To use TLS1.v2 you need to set a preference which auto selects the best method available (and possibly less secure outside of this Jamf context):

/Library/Python/2.7//site-packages/python_jss-1.5.0-py2.7.egg/jss/tlsadapter.py

change:

ssl_version=ssl.PROTOCOL_TLSv1

to:

ssl_version=ssl.PROTOCOL_SSLv23

Kudos to the answer here: https://stackoverflow.com/questions/26731517/using-tls1-2-with-ftplib-in-python-2-7

I used this command to help find the erroring code on my machine:

grep -r "ssl_version=" /Library/Python/2.7/

ddcdennisb commented 5 years ago

This worked to resolve my issue! Thanks!

ehemmete commented 5 years ago

This worked for me as well, but my tlsadapter.py was at a different path. /Library/Python/2.7/site-packages/jss/tlsadapter.py Putting it out there incase someone else has this path instead of the one above.