jython使用urllib2发出请求抛出一般SSLEngine

时间:2015-08-29 23:20:51

标签: python ssl urllib2 jython

我正在尝试使用jython进行AJAX调用。该服务器需要'session.id'才能获得授权。

url = 'https://somewebsite.com:8443/executor?pa=p1&pb=p2&session.id=ac8884bc-33f2-46e9-9893-5c7b92de5d5e'
urllib2.urlopen(url).read()

我在python上运行它,它工作正常。 但是当我在jython上运行它时,会抛出异常。回溯堆栈是:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 421, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/Users/zsun/jython2.7.0/Lib/urllib2.py", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 1] General SSLEngine problem (javax.net.ssl.SSLHandshakeException: General SSLEngine problem)>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您很可能正在处理未签名的证书。

由于Java 总是默认检查证书,即使您在请求中使用了verify = True参数,请查看此内容以查找仅限Jython的解决方案:

http://tech.pedersen-live.com/2010/10/trusting-all-certificates-in-jython/