unknown protocol error when connecting to an server via ssl

Discussion in 'Python' started by christian_stengel, Jan 26, 2005.

  1. Hi *,

    I have just started to learn python and I am having a problem with
    an python client connecting to a perl server using ssl (I tried this
    with pyOpenSSL and with the build in SSL Module).

    I don't want to check a cerificate, so i simply tried a

    from OpenSSL import SSL

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(("127.0.0.1", 2000)

    s.sendall("100 Hello\n")

    ctx = SSL.Context(SSL.SSLv23_METHOD)
    ctx.set_verify(SSL_VERIFY_NONE,self.verify_cb)
    ss = SSL.Connection(ctx,s)
    ss.set_connect_state()

    ss.sendall("101 User\n")

    when writeing the 101 I'll get an SSL23_GET_SERVER_HELLO
    unknown protocol error. If I don't do the ssl stuff, everything
    works.

    I also tried this with the socket.ssl(s,None, None) to get a secure
    socket - but I got the same error.

    The server is not written by me - so I can't change that to python.
    The problem is, that there is first an unencrypted socket, that is
    converted to a secure socket.

    the perl (server) code is something like this:

    # creating a socket
    $socket = IO::Socket::INET->new(Listen => 5,
    LocalPort => 2000,
    Timeout => 15,
    Resue => 1,
    Proto => 'tcp');

    # some more code

    # accepting a remote connection
    $session = $socket->accept;

    # some more code

    # convert the Socket to an ssl socket
    $sslsocket = IO::Socket::SSL::socket_to_SSL($session,
    SSL_verify_mode => 0x00)

    # some more code

    Does anybody know, where the UNKNOWN PROTOCOL error
    comes from? I have changed the connection Mode to
    SSLv2_METHOD but this gave me an GET_SERVER_HELLO
    read wrong packet type error.

    I have done this with python 2.3.4 under linux - and the perl stuff
    is done via the IO-Socket-SSL package.

    Thx,

    Chris
    christian_stengel, Jan 26, 2005
    #1
    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. Manish Jethani
    Replies:
    0
    Views:
    553
    Manish Jethani
    Dec 21, 2003
  2. Robert
    Replies:
    0
    Views:
    702
    Robert
    Apr 5, 2005
  3. Benjamin Schollnick
    Replies:
    0
    Views:
    780
    Benjamin Schollnick
    Apr 20, 2005
  4. John Reese
    Replies:
    5
    Views:
    26,554
    John Reese
    Jul 17, 2005
  5. Robert
    Replies:
    0
    Views:
    1,470
    Robert
    Aug 31, 2005
Loading...

Share This Page