Skip to content

Commit d41228c

Browse files
Fix logic for multiple separate paths in single chain
1 parent 0e9a954 commit d41228c

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/snowflake/connector/crl.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,18 @@ def traverse_chain(cert: x509.Certificate) -> CRLValidationResult | None:
373373
return CRLValidationResult.REVOKED
374374

375375
is_being_visited.add(chain[0].subject)
376-
return traverse_chain(chain[0])
376+
error_result = False
377+
revoked_result = False
378+
for cert in subject_certificates[chain[0].subject]:
379+
result = traverse_chain(cert)
380+
if result == CRLValidationResult.UNREVOKED:
381+
return result
382+
error_result |= result == CRLValidationResult.ERROR
383+
revoked_result |= result == CRLValidationResult.REVOKED
384+
385+
if error_result or not revoked_result:
386+
return CRLValidationResult.ERROR
387+
return CRLValidationResult.REVOKED
377388

378389
def _is_certificate_trusted_by_os(self, cert: x509.Certificate) -> bool:
379390
if trusted_cert := self._trusted_ca.get(cert.subject):

test/unit/test_crl.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -636,25 +636,17 @@ def test_cross_signed_certificate_chain(cert_gen, session_manager):
636636
]
637637
assert not validator.validate_certificate_chains(chains)
638638

639-
640-
def test_cross_signed_certificate_chain_revoked_CA(cert_gen, session_manager):
641-
chain = cert_gen.create_cross_signed_chain()
639+
# mingled A and B paths passed in one chain - A has no connection to CA, B has
642640
chains = [
643641
[
644642
chain.leafA,
645643
chain.AsignB,
646644
chain.leafB,
647-
chain.BsignA,
645+
# chain.BsignA,
648646
chain.rootB,
649-
chain.rootA,
647+
# chain.rootA,
650648
]
651649
]
652-
validator = CRLValidator(
653-
session_manager,
654-
cert_revocation_check_mode=CertRevocationCheckMode.ENABLED,
655-
allow_certificates_without_crl_url=True,
656-
trusted_certificates=[cert_gen.ca_certificate],
657-
)
658650
assert validator.validate_certificate_chains(chains)
659651

660652

0 commit comments

Comments
 (0)