unknown protocol error when connecting to an server via ssl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • christian_stengel

    #1

    unknown protocol error when connecting to an server via ssl


    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(s ocket.AF_INET, socket.SOCK_STR EAM)
    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_SERVE R_HELLO
    unknown protocol error. If I don't do the ssl stuff, everything
    works.

    I also tried this with the socket.ssl(s,No ne, 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::INE T->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_HELL O
    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



Working...