Unverified Commit 35772f8b authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

Workaround for datetime exception in Stem for weird ed25519 certs.

There's few bridges whose ed25519 certificates contain the year 491869, which
the datetime module (called from Stem) believes "out of range".  So instead
we'll parse the descriptors one at a time and catch the errors as we go.

 * FIXES #26023: https://bugs.torproject.org/26023
parent 37e126f3
...@@ -161,7 +161,19 @@ def parseServerDescriptorsFile(filename, validate=True): ...@@ -161,7 +161,19 @@ def parseServerDescriptorsFile(filename, validate=True):
logging.info("Parsing server descriptors with Stem: %s" % filename) logging.info("Parsing server descriptors with Stem: %s" % filename)
descriptorType = 'server-descriptor 1.0' descriptorType = 'server-descriptor 1.0'
document = parse_file(filename, descriptorType, validate=validate) document = parse_file(filename, descriptorType, validate=validate)
routers = list(document) routers = list()
# Work around https://bugs.torproject.org/26023 by parsing each descriptor
# at a time and catching any errors not handled in stem:
while True:
try:
routers.append(document.next())
except StopIteration:
break
except Exception as error:
logging.debug("Error while parsing a bridge server descriptor: %s"
% error)
return routers return routers
def __cmp_published__(x, y): def __cmp_published__(x, y):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment