Saturday 15 June 2013

networking - demo python server client interaction -


I'm new to networking normally and I'm trying to establish a simple exchange between the python server and the client I am

This is the code for the server

  import socket, SSL def DOP (signal, data): print "HLLO" DEF deal_V_ synthesis (connstream): data = connstream. () #null data means that the customer has ended up with the data with us: if not (Konstream, Data): # We will assume that do_something returns incorrect # when we have client break data = connstream.read () newsocket , Fromaddr = bindsocket.accept () print "connection installation" connstream: # client bindsocket = socket.socket () bindsocket.bind (('127.0.0.1', 10024)) bindsocket.listen (5), when Central finished with True = ssl.wrap_socket (newsocket, server_side = true, ca_certs = no, certfile = try "cert.pem", keyfile = "privatekey.pem", SSL_VERSION = ssl.PROTOCOL_TLSv1): deal_with_client ( connstream) finally: connstream.shutdown (socket .SHUT_RDWR) connstream.c Client.py  
  is the code to import the socket, ssl clientsocket = socket.socket () ssl_sock = ssl.wrap_socket ( )   

clientsocket, certfile = "cert.pem", cert_reqs = ssl.CERT_REQUIRED) Print ssl_sock.getpeername (ssl_sock.connect (( '127.0.0.1', 10024))) print ssl_sock .getpeercert () data = ssl_sock.recv (1024) Ssl_sock.close () print 'received', repr (data)

I created "cert.pem" and "privatekey.pem" Created using openssl Land.

  traceback (most recent call final): file "server.py", line 30, & lt; Module & gt; SSL_VERSION = ssl.PROTOCOL_TLSv1), file "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line = cipher in 344 wrap_socket cipher) file "/ System / Library / the framework / Python.framework / version "__init__ self.do_handshake, line 121, () the file" / 2.7 / lib / python2.7 / ssl.py /System/Library/Frameworks/Python.framework/Versions/2.7/lib/ python2.7 / ssl.py ", line 283, do_handshake self._sslobj.do_handshake) ssl.SSLError in (: [errno 8] _ssl.c: 499: the violation of EOF protocol   

I was thinking that if someone knows, then I can tell in the right direction. I really want to use this SSL bitdate, but I will be ready to switch to TLS if this is a better way.

It may be that the sockets are not running with a compatible SSL version, in your client There should also be a "ssl.PROTOCOL_TLSv1" compatible version (or remove it from server and also use default value). Googling You Can Find Many Examples of Socket Communications

No comments:

Post a Comment