HTTPS页面的Jython urllib2.urlopen出现问题 [英] Problem with Jython urllib2.urlopen for HTTPS pages
问题描述
我有一个使用urllib2通过https协议获取页面的python程序:
I have a python program using urllib2 to GET a page via https protocol:
urllib2.urlopen('https://mywebsite')
使用python解释器运行此脚本没有问题,但是使用Jython解释器运行时,出现此错误:
I have no problem running this script using python interpreter, but when running with Jython interpreter, I got this error:
urllib2.URLError: <urlopen error (-1,'SSL handshake exception')>
我还需要做其他事情才能使urllib2.urlopen
与https地址一起工作吗?
Do I need to do something else to make urllib2.urlopen
work with an https address?
推荐答案
我认为Jython使用Java SSL实现,因此您需要将服务器的证书添加到密钥库中.这是因为Java总是检查证书的有效性. 安装证书 还有两种不检查有效性的方法,使用Java代码和纯Jython .
I think Jython use the Java SSL implementation, so you'll need to add the server's certificate to your keystore. That's because Java always checks the certificate validity. Installing a certificate And two ways of not checking the validity, with java code and pure Jython.
这篇关于HTTPS页面的Jython urllib2.urlopen出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!