glyph / txsni

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

Loading an empty PEM gives a confusing error #8

Open hawkowl opened 8 years ago

hawkowl commented 8 years ago
2016-05-08 22:04:02+0800 [-] From cffi callback <function selectContext at 0x1090b3de8>:
2016-05-08 22:04:02+0800 [-] Traceback (most recent call last):
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1002, in wrapper
2016-05-08 22:04:02+0800 [-]     callback(Connection._reverse_mapping[ssl])
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/txsni/snimap.py", line 23, in selectContext
2016-05-08 22:04:02+0800 [-]     self.mapping[connection.get_servername()]
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/txacme/challenges.py", line 32, in __getitem__
2016-05-08 22:04:02+0800 [-]     return self.underlay[key]
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/txsni/snimap.py", line 39, in __getitem__
2016-05-08 22:04:02+0800 [-]     return certificateOptionsFromPileOfPEM(filePath.getContent())
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/txsni/only_noticed_pypi_pem_after_i_wrote_this.py", line 32, in certificateOptionsFromPileOfPEM
2016-05-08 22:04:02+0800 [-]     objects = objectsFromPEM(pemdata)
2016-05-08 22:04:02+0800 [-]   File "/Users/red/venvs/commands/lib/python2.7/site-packages/txsni/only_noticed_pypi_pem_after_i_wrote_this.py", line 22, in objectsFromPEM
2016-05-08 22:04:02+0800 [-]     blobs[-1] += line
2016-05-08 22:04:02+0800 [-] UnboundLocalError: local variable 'blobs' referenced before assignment
mithrandi commented 8 years ago

I think "pypi_pem" does a better job of handling this, so maybe porting to that would be the best way to resolve this.