Using Python SSL

skreech at my-deja.com skreech at my-deja.com
Fri Jan 12 16:29:54 EST 2001


I'm fairly experienced with using sockets in
Python... I've written two or three small programs
using sockets, nothing major. Python's
documentation on sockets is very good, and socket
programming in general is well documented too
(Beej's socket programming guide for example).
I've wanted to try implimenting SSL in the socket
programs by trying to use mxCrypto and Python's
SSL in the socket module. Not only have I been
unsuccessful trying to find out how to use
socket.SSL from the sourcecode and httplib.py, but
I've been even less successful in looking for
documentation on the internet on how to use SSL in
Python.

Since there seems to be little demand for
documentation, it seems like theres some real
obvious way to use it. I've successfully generated
a key and a self-signed certificate with openssl's
utilities, but when I try to use the socket.ssl
function I get SSL_connect errors. What is wrong
is probably obvious, but I can barely find any
example code to go off of.

The client program I've thrown together to test
socket stuff is basically this:

conn = socket(AF_INET, SOCK_STREAM)
conn.connect(('localhost', 13456))
sslconn = ssl(conn, "ckey", "ccert")

And the server is basically so:

sock = socket(AF_INET, SOCK_STREAM)
sock.bind(("", 13456))
sock.listen(1)
conn, addr = sock.accept()
sslconn = ssl(conn, "skey", "scert")

The exact error is like:
    sslconn = socket.ssl(conn, "skey", "scert")
socket.sslerror: SSL_connect error

And the same error occurs with both programs.
Python has been compiled with SSL support with
OpenSSL 0.9.6, also.

I donno where to go from here, so any help would
be appreceated.

Gavin Cooper


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list