can't send large messages over SSL socket

Discussion in 'Python' started by Bryan, Mar 10, 2006.

  1. Bryan

    Bryan Guest

    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
     
    Bryan, Mar 10, 2006
    #1
    1. Advertising

  2. Bryan

    Guest

    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).
     
    , Mar 16, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. final74
    Replies:
    6
    Views:
    580
    final74
    Jul 27, 2005
  2. Krzysztof Pa¼
    Replies:
    1
    Views:
    715
    Krzysztof Pa¼
    Sep 26, 2003
  3. Robert
    Replies:
    2
    Views:
    2,017
    Robert
    Jun 10, 2004
  4. B. W.
    Replies:
    2
    Views:
    145
    Eric Bohlman
    May 20, 2004
  5. Replies:
    1
    Views:
    306
Loading...

Share This Page