Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Jython urllib2.urlopen for HTTPS pages

Tags:

jython

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?

like image 214
ycseattle Avatar asked Sep 17 '25 03:09

ycseattle


1 Answers

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.

like image 118
Daniel Teply Avatar answered Sep 19 '25 14:09

Daniel Teply