HTTPS页面的Jython urllib2.urlopen出现问题 [英] Problem with Jython urllib2.urlopen for HTTPS pages

查看:119
本文介绍了HTTPS页面的Jython urllib2.urlopen出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆