[stem/master] Only require onion addresses when decrypting

commit 60864adc966a03ec9d31aa2312c5068286ac73fa Author: Damian Johnson <atagar@torproject.org> Date: Wed Sep 4 17:59:03 2019 -0700 Only require onion addresses when decrypting Minor tweek so a few of our tests can pass... ====================================================================== ERROR: test_invalid_lifetime ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/unit/descriptor/hidden_service_v3.py", line 110, in test_invalid_lifetime expect_invalid_attr(self, {'descriptor-lifetime': test_value}, 'lifetime') File "/home/atagar/Desktop/stem/test/unit/descriptor/__init__.py", line 41, in base_expect_invalid_attr return base_expect_invalid_attr_for_text(cls, default_attr, default_value, test, cls.content(desc_attrs), attr, expected_value) File "/home/atagar/Desktop/stem/test/unit/descriptor/__init__.py", line 52, in base_expect_invalid_attr_for_text desc = cls(desc_text, validate = False) File "/home/atagar/Desktop/stem/stem/descriptor/hidden_service.py", line 540, in __init__ raise ValueError("The onion address MUST be provided to parse a V3 descriptor") ValueError: The onion address MUST be provided to parse a V3 descriptor --- stem/descriptor/hidden_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stem/descriptor/hidden_service.py b/stem/descriptor/hidden_service.py index 150ba368..1c51b7b2 100644 --- a/stem/descriptor/hidden_service.py +++ b/stem/descriptor/hidden_service.py @@ -535,9 +535,6 @@ class HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor): """ super(HiddenServiceDescriptorV3, self).__init__(raw_contents, lazy_load = not validate) entries = _descriptor_components(raw_contents, validate) - - if onion_address == None: - raise ValueError("The onion address MUST be provided to parse a V3 descriptor") self.onion_address = onion_address # XXX Do this parsing in its own function @@ -568,6 +565,9 @@ class HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor): # ASN XXX need to verify descriptor signature (for now we trust Tor to do it) if not skip_crypto_validation and stem.prereq.is_crypto_available(): + if self.onion_address is None: + raise ValueError("Onion address is required to decrypt v3 hidden service descriptors") + plaintext = self.decrypt_descriptor(desc_signing_cert) def decrypt_descriptor(self, desc_signing_cert):
participants (1)
-
atagar@torproject.org