python ssl-server-socket - exception at handshake
<p>I need to know the exact data-format form an ssl-stream. I only know there is some json like format in the stream. </p>

<p>To get the data I shutdown the server and started my own ssl-server-socket:</p>

<pre><code>import socket
import ssl

HOST, PORT = '0.0.0.0', 44444

SERVER_KEY = ...
SERVER_CERT = ... 
SERVER_CA_CERT = ...

def write_to_file(filename, buf):
    fp = open(filename, 'wb')
    fp.write(buf)
    fp.close()

#create server socket
Ssock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#wrap server socket
SwrappedSocket = ssl.wrap_socket(Ssock, certfile=SERVER_CERT, server_side=True, keyfile=SERVER_KEY, ca_certs=SERVER_CA_CERT)
SwrappedSocket.bind(('0.0.0.0', PORT))

#listen for client connections
SwrappedSocket.listen(5)
#accept conncetions
print "start listening on port: " + str(PORT)
i = 0
while 1:
    (clientsocket, address) = SwrappedSocket.accept()
    print "Connection from client established"
    in_buffer = clientsocket.recv(66000)
    filename = '/root/received_data' + str(i) + '.log'
    write_to_file(filename, in_buffer)
    i+=1
</code></pre>

<p>but during the handshake:</p>

<pre><code>Traceback (most recent call last):
  File "intercept.py", line 68, in &lt;module&gt;
    (clientsocket, address) = SwrappedSocket.accept()
  File "/usr/lib/python2.7/ssl.py", line 840, in accept
    server_side=True)
  File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
  File "/usr/lib/python2.7/ssl.py", line 566, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:581)
</code></pre>