<urlopen error (-1, 'SSL exception: Differences between the SSL socket behaviour of cpython vs. jython are explained on the wiki
Question: I'm 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'm running 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 the 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've been trying and the issue is definitely with the long
authentication token. I have a feeling it might be some encoding issue. There
was a similar question posted
[here](http://stackoverflow.com/questions/33912074/https-get-using-jython)
before. I read it but it wasn't described properly. But it could be a good
reference to think off of.


Answer: It seems issue of certificate trust. <http://bugs.jython.org/issue1688>

There are these two options that will solve your problem.

> Jython is not like cpython. Cpython does not verify the chain of trust for
> server certificates. Jython does verify the chain of trust, and will refuse
> to open the connection if it cannot verify the server.
>
> So you have two options.
>
>   1. Disable certificate checking on 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/>
>
>   2. Add your (self-signed?) certificate to your local java trust store, so
> that your client will trust your server.
>

>
> Google("java install self-signed certificate")

Another reason for this can be due to incompactible 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
>
> Swapping to Oracle JDK 7 did the trick.

Please check if this solves the problem, as per implementation of jython and
error, issue is due to HTTPS(SSL layer)
<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),
    

