<urlopen error (-1, 'SSL exception: Differences between the SSL socket behaviour of cpython vs. jython are explained on the wiki
<p>I'm using the following code.</p>

<pre><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()
</code></pre>

<p>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</p>

<pre><code>(-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')
</code></pre>

<p>Any ideas why this is happening?</p>

<p>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 <a href="http://stackoverflow.com/questions/33912074/https-get-using-jython">here</a> before. I read it but it wasn't described properly. But it could be a good reference to think off of.</p>

<p>It seems issue of certificate trust.
<a href="http://bugs.jython.org/issue1688" rel="nofollow">http://bugs.jython.org/issue1688</a></p>

<p>There are these two options that will solve your problem.</p>

<blockquote>
  <p>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.</p>
  
  <p>So you have two options.</p>
  
  <ol>
  <li>Disable certificate checking on jython</li>
  </ol>
  
  <p><a href="http://jython.xhaus.com/installing-an-all-trusting-security-provider-on-java-and-jython/" rel="nofollow">http://jython.xhaus.com/installing-an-all-trusting-security-provider-on-java-and-jython/</a>
  <a href="http://tech.pedersen-live.com/2010/10/trusting-all-certificates-in-jython/" rel="nofollow">http://tech.pedersen-live.com/2010/10/trusting-all-certificates-in-jython/</a></p>
  
  <ol start="2">
  <li>Add your (self-signed?) certificate to your local java trust store, so that your client will trust your server.</li>
  </ol>
  
  <p>Google("java install self-signed certificate")</p>
</blockquote>

<p>Another reason for this can be due to incompactible version of python and java (<a href="https://github.com/geoscript/geoscript-py/issues/32" rel="nofollow">https://github.com/geoscript/geoscript-py/issues/32</a>)</p>

<blockquote>
  <p>I just tried with Jython 2.5.3 and JDK 1.7 on Mac and was able to run
  ez_setup.py.</p>
  
  <p>Java version: [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]
  on java1.7.0_51</p>
  
  <p>Swapping to Oracle JDK 7 did the trick.</p>
</blockquote>

<p>Please check if this solves the problem, as per implementation of jython and error, issue is due to HTTPS(SSL layer) <a href="https://github.com/int3/jython/blob/master/Lib/socket.py" rel="nofollow">https://github.com/int3/jython/blob/master/Lib/socket.py</a></p>

<pre><code># 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),
</code></pre>

python ssl jython