SSL socket in 2.0

thaiwey at my-deja.com thaiwey at my-deja.com
Wed Dec 6 20:35:18 EST 2000


In article <90mcv1$9c$1 at nnrp1.deja.com>,
  thaiwey at my-deja.com wrote:
> In article <90lpjm$edp$1 at nnrp1.deja.com>,
>   thaiwey at my-deja.com wrote:
> > hi,
> >
> > i have been trying to compile the socket module with SSL support on
my
> > nt without much success. i was using the pcbuild.dsw in MSVC 6.0.
can
> > anyone advice me as to how i can set the necessary flags in the
> project
> > options/settings to turn on SSL.
> >
> > i have already compiled openssl-0.9.6 for my machine. i have also
> added
> > "USE_SSL" in the preprocessor definitions, paths to openssl in the
> > include directories, library path to openssl, and "libeay32.lib
> > ssleay32.lib" to the Object\library modules section. when
compiling, i
> > keep getting the following errors:
> >
> > Compiling...
> > socketmodule.c
> > G:\Python-2.0\Modules\socketmodule.c(2112) : error C2099:
initializer
> > is not a constant
> > G:\Python-2.0\Modules\socketmodule.c(2114) : warning C4047:
> > 'initializing' : 'int ' differs in levels of indirection from 'char
> [4]'
> > G:\Python-2.0\Modules\socketmodule.c(2115) : warning C4047:
> > 'initializing' : 'char *' differs in levels of indirection from
> > 'unsigned int '
> > G:\Python-2.0\Modules\socketmodule.c(2118) : warning C4047:
> > 'initializing' : 'int ' differs in levels of indirection from 'void
> > (__cdecl *)(struct _object *)'
> > G:\Python-2.0\Modules\socketmodule.c(2120) : warning C4047:
> > 'initializing' : 'int (__cdecl *)(struct _object *,struct _iobuf
*,int
> > )' differs in levels of indirection from 'struct _object *(__cdecl
*)
> > (struct _object *,char *)'
> > Error executing cl.exe.
> >
> > thanks.
> >
> > tw
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> actually, i found out that i can change some code in socketmodule.c so
> that it compiles. i found the answer in faq
> (http://www.python.org/doc/FAQ.html). but after that, when i try to
use
> it, i keep getting this error:
>
> Traceback (most recent call last):
>   File "httplib.py", line 819, in ?
>     test()
>   File "httplib.py", line 805, in test
>     hs.connect(host)
>   File "httplib.py", line 660, in connect
>     self._conn.connect()
>   File "httplib.py", line 616, in connect
>     ssl = socket.ssl(sock, self.key_file, self.cert_file)
> TypeError: ssl, argument 1: expected socket, instance found
>
> does anyone know why?
>
> tw
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

great. found the problem. not sure if this solution is correct. but it
seems that socket.ssl expect a socket as the first argument. so instead
of passing in sock (a _socketobject) in line 616 of httplib.py, we
should be passing in sock._sock. after changing that line to:
    ssl = socket.ssl(sock._sock, self.key_file, self.cert_file)
the problem seemed fixed. hope this will be useful to someone else on
the net. thanks.

tw


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list