Tuesday, January 4, 2011

SSL socket

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 5865))

ssl_sock = socket.ssl(s)
# Set a simple HTTP request -- use httplib in actual code.
ssl_sock.write("""GET / HTTP/1.0\r\n
                            Host: www.verisign.com:443\r\n
                            Proxy-Connection: keep-alive\r\n\r\n""")

data = ssl_sock.read()
print data


# Note that you need to close the underlying socket, not the SSL object.
del ssl_sock
s.close()

2 comments:

  1. Greate pieces. Keep writing such kind of info on your blog. Im really impressed by your site.
    Hey there, You have performed an incredible job. I'll definitely digg it and in my view suggest to my friends. I am confident they'll be benefited from this web site.

    ReplyDelete
  2. Excellent site you've got here.. It's difficult to find high-quality writing like yours nowadays. I really appreciate people like you! Take care!!

    ReplyDelete