Reading from an SSL connector in Twisted

I am trying to implement an SSL client in Twisted, which simply needs to connect to a socket and read binary data (in particular data tuples). I got the code to the point where it seems that the connection and disconnection are successful, but the data is not read from the socket.

class FeedbackHandler(LineReceiver):
  MAX_LENGTH = 1024*1024

  def connectionMade(self):
    log.debug('feedbackHandler connectionMade')

  def rawDataReceived(self, data):
    log.debug('feedbackHandler rawDataReceived %s' % binascii.hexlify(data))
    self.io.write(data)

  def lineReceived(self, data):
    log.debug('feedbackHandler lineReceived %s' % binascii.hexlify(data))
    self.io.write(data)

  def connectionLost(self, reason):
    log.debug('feedbackHandler connectionLost %s' % reason)
    self.deferred.callback(self.io.getValue())
    io.close()

And the code that disables it:

factory = self.clientProtocolFactory() # a ClientFactory instance
context = self.getContextFactory(CERT_FILE) # a ClientContextFactory 
reactor.connectSSL(server, port, factory, context)

However, at startup, none of the methods received are called, regardless of setRawMode. Do not read anything from the server? connectionMadeand connectionLostare called immediately upon connection and terminate with an error instance ConnectionDone.

+3
source share
1 answer

ssldump wirehark. - , , . SSL - , , , . , .

+2

Source: https://habr.com/ru/post/1727088/


All Articles