|
2007-01-26 First impressions of pyOpenSSLpyOpenSSL is a high-level Python wrapper around a subset of the OpenSSL library (to quote it). It was pulled onto my machines recently as part of a Fedora update, and since I'm currently interested in OpenSSL-related things I decided to play around with it to try it out. After writing some basic stuff, I have to say that I like it. It's not entirely documented (and for some things you really want to read the OpenSSL manpages too), but it works fine. It's also nicely simple to use; my test program to connect to a server and extract its SSL certificate is only 40 lines. Here's the gotchas and stuff I know about so far:
These are pretty much minor concerns, though; the only one that
required me to do some serious delving was the Sidebar: a simple example clientHere's an example of how you'd use the client side of pyOpenSSL (without error checking and the like):
import socket
from OpenSSL import SSL
def ding(host, port, msg):
s = socket.socket()
# TLSv1 chosen more or less arbitrarily
cx = SSL.Context(SSL.TLSv1_METHOD)
cn = SSL.Connection(cx, s)
cn.connect((host, port))
cn.do_handshake()
cn.sendall(msg)
tl = []
try:
while 1:
r = cn.recv(8192)
tl.append(r)
except SSL.ZeroReturnError:
pass
cn.shutdown()
cn.close()
return "".join(tl)
As far as I can tell from (2 comments.)
python/PyOpenSSLComments written at 23:13:16; Add Comment
|
These are my WanderingThoughts GettingAround This is part of CSpace, and is written by ChrisSiebenmann. * * * Atom feeds are available; see the bottom of most pages. Categories: links, linux, programming, python, snark, solaris, spam, sysadmin, tech, unix, web |