can't send large messages over SSL socket

B

Bryan

i'm having some trouble this code which i hope someone can help me with. the
following client side code works correctly if the length of the message being
sent in the POST request is 16384 (1024 * 16) chars or less. if the length of
message is greater than 16384 an

OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')

exception is raised. this is a port of code that exists in c++ and java
implementations where they are able to send messages with lengths of 100,000
bytes. all three implementations are using openssl 0.9.7d and are sharing the
exact same binary in a common area, so odds are openssl is not the problem. as
for python, i'm using python 2.4.2 and pyOpenSSL wrapper 0.6. is this a
limitation with httplib or pyopensll? i googled for this problem, but came up
empty handed.



import socket
import httplib
import SSL

def verify(conn, cert, err, width, ok):
return ok

header = {'Content-Type': 'text/foo', 'Connection': 'Keep-Alive'}

ctx = SSL.Context(SSL.SSLv3_METHOD)
ctx.set_verify(SSL.VERIFY_NONE, verify)
ctx.set_options(SSL.OP_ALL | SSL.OP_NO_SSLv2)
ctx.set_cipher_list('ALL:!aNULL:!eNULL:!LOW:!EXP:!MD5:mad:STRENGTH')

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssl = SSL.Connection(ctx, sock)
ssl.connect((host, port))

con = httplib.HTTPSConnection(host, port)
con.sock = httplib.FakeSocket(sock, ssl)


# raises exception if len(message) > 1024*16
con.request('POST', '/foo', message, header)

res = con.getresponse().read()



thanks,

bryan
 
D

donk71

Well the first thing to note is that the maximum record length in SSL
is exactly 16384. SSL/TLS does not preserve message boundaries - it is
up to the application to determine if there are multiple messages in a
single record, or a single message spanning multiple records. Sounds
like the particular wrapper function is not properly chunking the
message up into multiple records (or just does not support large
messages).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top