Problem with Jython urllib2.urlopen for HTTPS pages

吃可爱长大的小学妹 提交于 2019-12-18 08:58:28

问题


I have a python program using urllib2 to GET a page via https protocol:

urllib2.urlopen('https://mywebsite')

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')>

Do I need to do something else to make urllib2.urlopen work with an https address?


回答1:


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://stackoverflow.com/questions/6500010/problem-with-jython-urllib2-urlopen-for-https-pages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!