<urlopen error (-1, 'SSL exception: Differences between cpython vs. jython SSL socket behavior are explained on the wiki

I am using the following code.

import urllib2 #Setting proxy myProxy = {'https':'https://proxy.example.com:8080'} proxy = urllib2.ProxyHandler(myProxy) opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) #Access URL auth_token = "realLy_loNg_AuTheNicaTion_toKen" headers={"Content-Type":"application/json", "charset": "UTF-8", "Authorization": "Bearer %s" %auth_token} url = "https://example.com/something" req = urllib2.Request(url, None, headers) reply = urllib2.urlopen(req) print reply.getcode() 

I run the above as a Jython script in nGrinder. When I run the same script on my system with Jython, it works fine and returns 200 (OK status code). When I run it on nGrinder, I get an error

 (-1, 'SSL exception: Differences between the SSL socket behaviour of cpython vs. jython are explained on the wiki: http://wiki.python.org/jython/NewSocketModule#SSL_Support') 

Any ideas why this is happening?

EDIT: I tried, and the problem is definitely related to the long authentication token. I have a feeling that this could be a coding problem. Earlier there was a similar question here . I read it, but it was not described correctly. But this may be a good reference to come up with.

+6
source share
1 answer

There seems to be a certificate trust issue. http://bugs.jython.org/issue1688

There are two options that can help solve your problem.

Jython is not like cpython. Cpython does not check the trust chain for server certificates. Jython checks the trust chain and refuses to open the connection if it cannot verify the server.

So, you have two options.

  • Disable certificate verification in jython

http://jython.xhaus.com/installing-an-all-trusting-security-provider-on-java-and-jython/ http://tech.pedersen-live.com/2010/10/trusting-all- certificates-in-jython /

  1. Add your (self-signed?) Certificate to your Java trust store so that your client trusts your server.

Google ("java install self-signed certificate")

Another reason for this may be due to an incompatible version of python and java ( https://github.com/geoscript/geoscript-py/issues/32 )

I just tried with Jython 2.5.3 and JDK 1.7 on Mac and was able to run ez_setup.py.

Java version: [Java HotSpot (TM) 64-bit server VM (Oracle Corporation)] on java1.7.0_51

Switching to Oracle JDK 7 did the trick.

Please check if this problem resolves the jython implementation problem and errors, the problem is related to HTTPS (SSL level) https://github.com/int3/jython/blob/master/Lib/socket.py

 # These error codes are currently wrong: getting them correct is going to require # some investigation. Cpython 2.6 introduced extensive SSL support. (javax.net.ssl.SSLException, ALL) : lambda x: sslerror(-1, 'SSL exception'+_ssl_message), 
0
source

All Articles