[PYTHON-CRYPTO] Execute connect_ssl() twice to connect - is this right?

Latitia Haskins latitia.haskins at GMAIL.COM
Wed Feb 28 15:45:05 CET 2007


Hi all,

I would like to verify some behavior that I observe in my code when I
connect a client and server using M2Crypto. I am finding that I have to
execute the connect_ssl() method twice in order for a connection to be made
between the client and server. Is this right or am I doing something wrong?
Thanks for any information that anyone can give me.
Latitia

#----------- server ----------------
>>> import M2Crypto
>>> ss = M2Crypto.SSL.ssl_dispatcher()
>>> ss.ssl_ctx = M2Crypto.SSL.Context('tlsv1')
>>> ss.ssl_ctx.set_cipher_list('ADH-AES128-SHA')
>>> ss.ssl_ctx.set_tmp_dh('dhparam.pem')
>>> ss.ssl_ctx.set_tmp_dh_callback()
>>> ss.ssl_ctx.set_info_callback()
>>> ss.create_socket(ss.ssl_ctx)
>>> ss.set_reuse_addr()
>>> ss.socket.setblocking(0)
>>> ss.bind(('server.home.com', 8888))
>>> ss.listen(5)
>>> sa = ss.socket.accept()
LOOP: SSL accept: before/accept initialization

<<< s.connect_ssl() DONE HERE >>>

LOOP: SSL accept: SSLv3 read client hello A
LOOP: SSL accept: SSLv3 write server hello A
LOOP: SSL accept: SSLv3 write key exchange A
LOOP: SSL accept: SSLv3 write server done A
LOOP: SSL accept: SSLv3 flush data

<<< s.connect_ssl() DONE HERE >>>

LOOP: SSL accept: SSLv3 read client key exchange A
LOOP: SSL accept: SSLv3 read finished A
LOOP: SSL accept: SSLv3 write change cipher spec A
LOOP: SSL accept: SSLv3 write finished A
LOOP: SSL accept: SSLv3 flush data
INFO: SSL accept: SSL negotiation finished successfully
>>>

#--------- client -------------------------------
>>> import M2Crypto
>>> import socket
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> ctx = M2Crypto.SSL.Context('tlsv1')
>>> ctx.set_cipher_list('ADH-AES128-SHA')
>>> ctx.set_tmp_dh('dhparam.pem')
>>> ctx.set_tmp_dh_callback()
>>> ctx.set_info_callback()
>>> s = M2Crypto.SSL.Connection(ctx, sock)
>>> s.addr=('server.home.com', 8888)
>>> s.socket.connect(s.addr)
>>> s.setup_ssl()
>>> s.set_connect_state()
>>> s.setblocking(0)
>>> s.connect_ssl()
LOOP: SSL connect: before/connect initialization
LOOP: SSL connect: SSLv3 write client hello A
INFO: SSL connect: SSLv3 read server hello A
0
>>>
>>> s.connect_ssl()
LOOP: SSL connect: SSLv3 read server hello A
LOOP: SSL connect: SSLv3 read server key exchange A
LOOP: SSL connect: SSLv3 read server done A
LOOP: SSL connect: SSLv3 write client key exchange A
LOOP: SSL connect: SSLv3 write change cipher spec A
LOOP: SSL connect: SSLv3 write finished A
LOOP: SSL connect: SSLv3 flush data
INFO: SSL connect: SSLv3 read finished A
0
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-crypto/attachments/20070228/a938dd80/attachment.html>


More information about the python-crypto mailing list