python requests certificate error

Posted on
Fri Feb 02, 2018 9:12 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

python requests certificate error

when I run a python script in terminal on my mac min osx 10.13.3 its works fine when in on 10.11.3 it throws the following error:
Code: Select all
SLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

Code: Select all
import requests
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
unifiControllerSession  = requests.Session()
ret                     = unifiControllerSession.post(login_url, data =loginData, verify=False)

there is some discussion on the web on ld OSX ssl version .. when I do
openssl version i get:
OpenSSL 0.9.8zh 14 Jan 2016
on the old mac pro

is it easy to fix? anyone done this?

Karl

Posted on
Fri Feb 02, 2018 9:30 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

I am trying to replace curl with requests in python.
It is a general question .. with curl everything works .. but just wanted to convert to true python ..

The server I am trying to run it against is the unifi controller (locally). And in the plugin I don't want to have to deal with ssl version control ....

guess I will stay with curl. but why can CURL do it w/o any complains, does it come with its own ssl?


Karl

Posted on
Fri Feb 02, 2018 10:06 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

yes its different ..
Code: Select all
curl -V
curl 7.43.0 (x86_64-apple-darwin15.0.0) libcurl/7.43.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
and
Code: Select all
python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8zh 14 Jan 2016'


I guess I will just continue to use cURL, it works and it is fast ..

thanks for the help

Karl

and upgrading ssl runs into the apple sudo problem that it does not allow to change these preinstalled things .

Code: Select all
sudo mv /usr/bin/openssl /usr/bin/openssl-old
mv: rename /usr/bin/openssl to /usr/bin/openssl-old: Operation not permitted

Posted on
Fri Feb 02, 2018 10:56 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

... not giving up yet. trying to do :
Code: Select all
python
import sys
sys.path.insert(0,'/usr/local/Cellar/openssl/1.0.2n/bin/openssl')
import ssl

but it still imports from: /usr/bin/openssl.. ?

Code: Select all
ls /usr/local/Cellar/openssl/1.0.2n/
CHANGES         LICENSE         README         include         share
INSTALL_RECEIPT.json   NEWS         bin         lib


.. I guess this will be the job for the weekend

Karl

Posted on
Sat Feb 03, 2018 10:02 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: python requests certificate error

If you don't care about https validation, just tell requests to ignore certificate validation. I suspect that'll work.

[EDIT] - sorry, I see you were trying that already. Seems odd you'd get the SSL error in that case...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Feb 03, 2018 11:49 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: python requests certificate error

I wonder if this would help...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Feb 03, 2018 3:11 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

python requests certificate error

Yes that would do it. But the mac needs to be rebooted in recovery mode. For that I need to add a keyboard mouse and monitor and move it out of the closet...


Sent from my iPhone using Tapatalk

Posted on
Sat Feb 03, 2018 3:34 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

my question is: is this the only way ( its the only description i found after 6 hours of looking on the net) and how is anyone on el Capitan using python requests with ssl .. .. did it work once ?

Posted on
Sun Feb 04, 2018 12:27 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: python requests certificate error

kw123 wrote:
my question is: is this the only way ( its the only description i found after 6 hours of looking on the net) and how is anyone on el Capitan using python requests with ssl .. .. did it work once ?


viewtopic.php?t=20127&p=153954#p153954

Bottom line: it will only fail if the target site (Github in your case) starts refusing TLS 1.0 (maybe also 1.1) connections. If you are connecting to GitHub to do version checking I'd recommend not wasting your time. We'll have an API for checking versions on the plugin store pretty soon. We're also going to investigate to see if there's anything we can do on our end to ship with Indigo to help with the issue (though we're not super confident we can find a hack around this Apple bug).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Feb 04, 2018 12:36 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

python requests certificate error

No it’s not GitHub.
I have several servers that require ssl ie:
Mother/ sense
UniFi

For both curl works fine.

And under Sierra /high Sierra python requests works fine to.

Sent from my iPhone using Tapatalk

Posted on
Sun Feb 04, 2018 3:05 pm
DaveL17 offline
User avatar
Posts: 6742
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: python requests certificate error

kw123 wrote:
And under Sierra /high Sierra python requests works fine to.

IIRC, I could not get python requests to work under Sierra either with GitHub.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Feb 04, 2018 5:18 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: python requests certificate error

DaveL17 wrote:
kw123 wrote:
And under Sierra /high Sierra python requests works fine to.

IIRC, I could not get python requests to work under Sierra either with GitHub.


Yeah, for me Sierra still shows the old openssl version, but HS doesn't.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Feb 04, 2018 5:24 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

Sorry stand corrected. I only tested under high Sierra.


Sent from my iPhone using Tapatalk

Posted on
Sun Feb 04, 2018 7:18 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: python requests certificate error

My point of view if you have others using your plugins you can not assume the latest ops-sys or that users will install some difficult patches. Hence I will stick with curl. ...


Sent from my iPhone using Tapatalk

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests