[Stackless] Encrypted Sockets
Phoenix Sol
burninglabs at gmail.com
Wed Jan 9 01:08:40 CET 2008
> I see the socket.ssl() function accepts a socket object as its first
> parameter. Have you tried simply passing it an instance of
> stacklesssocket?
>
> Arnar
>
I would expect to be doing the same thing as urllib with stacklesssocket
here, but here goes:
______________________________
______________________________________________________
import sys
import stacklesssocket
import stackless
sys.modules["socket"] = stacklesssocket
import socket
# from http://docs.python.org/lib/socket-example.html:
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
s.connect(('www.verisign.com', 443))
ssl_sock = socket.ssl(s)
print repr(ssl_sock.server())
print repr(ssl_sock.issuer())
# Set a simple HTTP request -- use httplib in actual code.
ssl_sock.write("""GET / HTTP/1.0\r
Host: www.verisign.com\r\n\r\n""")
# Read a chunk of data. Will not necessarily
# read all the data returned by the server.
data = ssl_sock.read()
print data.read()
# Note that you need to close the underlying socket, not the SSL object.
del ssl_sock
s.close()
_________Result :___________________________________________________
Traceback (most recent call last):
File "ssl_socket_test.py", line 12, in <module>
ssl_sock = socket.ssl(s)
File "/usr/lib/stackless/Lib/socket.py", line 74, in ssl
return _realssl(sock, keyfile, certfile)
socket.sslerror: (2, 'The operation did not complete (read)')
___________________________________________________________________
Yep, same thing...
This is not to put any pressure on you, Richard! Thanks for sharing =-)
Phoenix Sol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20080108/67b14cc7/attachment.htm>
More information about the Stackless
mailing list