glyph / txsni

Simple support for running a TLS server with Twisted.
MIT License
25 stars 10 forks source link

txsni logs a TypeError when a connection without SNI is received. #14

Closed tomprince closed 8 years ago

tomprince commented 8 years ago
2016-08-12 09:26:38-0600 [-] From cffi callback <function selectContext at 0x00007f1dc9f03100>:
2016-08-12 09:26:38-0600 [-] Traceback (most recent call last):
2016-08-12 09:26:38-0600 [-]   File "/srv/t-web/virtualenv/site-packages/OpenSSL/SSL.py", line 1004, in wrapper
2016-08-12 09:26:38-0600 [-]     callback(Connection._reverse_mapping[ssl])
2016-08-12 09:26:38-0600 [-]   File "/srv/t-web/virtualenv/site-packages/txsni/snimap.py", line 23, in selectContext
2016-08-12 09:26:38-0600 [-]     self.mapping[connection.get_servername()]
2016-08-12 09:26:38-0600 [-]   File "/srv/t-web/virtualenv/site-packages/txsni/maputils.py", line 14, in __getitem__
2016-08-12 09:26:38-0600 [-]     value = self.mapping[key]
2016-08-12 09:26:38-0600 [-]   File "/srv/t-web/virtualenv/site-packages/txsni/snimap.py", line 35, in __getitem__
2016-08-12 09:26:38-0600 [-]     filePath = self.directoryPath.child(hostname + ".pem")
2016-08-12 09:26:38-0600 [-] TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
mithrandi commented 8 years ago

Do you have a way to reproduce this error? The traceback seems to indicate that the client is doing SNI, but with no hostname, which is a bit odd. If the client doesn't do SNI at all, then I would expect that the tlsext_servername_callback wouldn't be run.

mithrandi commented 8 years ago

Ah, I think this is fixed by 74aa2b89f0b6faca647960183c51e62b909fc063, but there hasn't been a new release yet?

tomprince commented 8 years ago

Actually, testing this, it looks like it was fixed in 0.1.6. I has just noticed this in the logs of twistedmatrix.com and hadn't investigated the details.