ssl error

Reid Nichol sigma at safepassage.ca
Sat Nov 17 14:40:22 EST 2001


I got a client/server app that I am triing to build and am having problems. 
 I created the key and cert with openssl as per 'man ssl'.  The socket 
seems to load it all find and think that the what's in the files are good.  
I can connect without ssl fine and dandy but when I goto use socket.ssl it 
blows up.

The error:
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", line 1285, in __call__
    return apply(self.func, args)
  File "main.py", line 57, in logon
    self.conn = self.connection.connect()# = connect()
  File "connect.py", line 18, in connect
    self.incoming = socket.ssl(self.clear_in, "ssl/dsakey.pem", 
"ssl/dsacert.pem")
sslerror: SSL_connect error

The error in my logs on my server if I try to connect to port 22:
Bad protocol version identification '\M^@\M^@\^A\^C\^A' from 192.168.0.2

I'm not really understanding what is going on here, ie where to start, 
which files to look at.  I've looked on the net and haven't found any 
examples of ssl under python (at least the built in module).

My relevant code for the client:
import socket
 
class connect:
  def __init__(self):
    self.HOST = ''
    self.IN_PORT  = 10006
    self.OUT_PORT = 10007
    self.clear_in = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
  def connect(self):
    self.clear_in.connect (('host', 22,))
    self.incoming = socket.ssl(self.clear_in, "ssl/dsakey.pem", 
"ssl/dsacert.pem")


And the server:
import socket

HOST = ''
IN_PORT  = 10006
 
in_in = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
in_in.bind((HOST, IN_PORT))
 
in_in.listen(1)
 
try:
        conn, addr = in_in.accept()
        incoming = socket.ssl(conn, "ssl/dsakey.pem", "ssl/dsacert.pem")
except socket.sslerror, msg:
        print 'ssler => ', socket.sslerror
        print 'sockr => ', socket.error
        print 'error => ', msg
 
 
print 'connected by => ', addr
conn.close()

-----
If you truly love the memory, you must set it free()!



More information about the Python-list mailing list