Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: James R Eagan <eaganj <at> bazza.com>
Subject: Re: Jython and SSL
Newsgroups: gmane.comp.lang.jython.user
Date: Tuesday 6th February 2007 14:44:46 UTC (over 10 years ago)
Hi Philipp,

The Python SSL libraries use a C implementation that would be non- 
trivial to port to Jython.  Furthermore, it is a longstanding bug  
that the Python SSL implementation performs no certificate  
validation.  That's like using an armored truck to deposit your  
paycheck to the bank, but never actually verifying that the guy you  
hand the check to is really the right guy.  Java, however, gets it  
right.

Can you use the Java libraries instead?  Here's what I do (in Jython  
2.1):

Cheers!
James

from com.sun.net.ssl.HttpsURLConnection import *

#...

             System.setProperty("java.protocol.handler.pkgs",
                                "com.sun.net.ssl.internal.www.protocol")

             loginURL = URL(service.getLoginURL())
             conn = loginURL.openConnection()
             self.status('Talking to %s...' % (loginURL))

             referer = service.getReferer()
             if referer is not None:
                 conn.setRequestProperty('Referer', referer)
             # We need both output and input
             conn.setDoInput(True)
             conn.setDoOutput(True)
             conn.setUseCaches(False)

             # Get the password
             password = service.getPassword()
             if password is None:
                 password = self.getPassword('%s password' %  
(service.name))
             elif password == '__useKeychain__':
                 password = self.getPasswordFromKeychain(service.name,
                                                          
service.username)

             out = PrintWriter(conn.getOutputStream())
             out.print('username=%s&password=%s' % (
                             URLEncoder.encode(service.username),
                             URLEncoder.encode(password)))
             for opt in service.options:
                 out.print('&%s' % (opt))
#            out.print('&foo=bar') # workaround for mower bug
             out.flush()
             out.close()


On Feb 6, 2007, at 09:28 , Philipp Walther wrote:

> Hi all,
>
> I'm quite new to Jython, so please bear with me if this has been
> discussed already somewhere..
>
> I'm trying to do a HTTPS Post with Client Authentication on a Windows
> Server, but I have
> no SSL available it seems..
>
> My code:
>     import httplib
>     conn = httplib.HTTPSConnection(HOSTNAME,key_file =  
> KEYFILE,cert_file
> = CERTFILE)
>     conn.putrequest('POST', '/invoke/ATR.B2B.Inbound.IDOC/ORDERS')
>     conn.putrequest('Content-Type', 'application/x-www-form- 
> urlencoded')
>     conn.endheaders()
>     conn.send(partbodygoesinhere)
>     response = conn.getresponse()
>     print response.read()
>
>
> But when executed I get:
> Traceback (innermost last):
>   File "", line 1, in ?
>   File "", line 28, in service
>   File "C:\Sonic70\Workbench7.0\eclipse\python_home\Lib\httplib.py",
> line 437, in putrequest
>   File "C:\Sonic70\Workbench7.0\eclipse\python_home\Lib\httplib.py",
> line 379, in send
>   File "C:\Sonic70\Workbench7.0\eclipse\python_home\Lib\httplib.py",
> line 639, in connect
> AttributeError: module 'socket' has no attribute 'ssl'
>
>
> Anybody got a solution? How can I compile a SSL module for jython? All
> suggestions are welcome :)
>
> Thanks in advance,
>
> Phil
>
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel?

> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Jython-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jython-users
>

--
It's dead, Jim.



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
 
CD: 12ms