By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,635 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,635 IT Pros & Developers. It's quick & easy.

unknown protocol error when connecting to an server via ssl

P: n/a

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(("", 2000)

s.sendall("100 Hello\n")

ctx = SSL.Context(SSL.SSLv23_METHOD)
ss = SSL.Connection(ctx,s)

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

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.



Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.