MCPcopy Create free account
hub / github.com/secdev/scapy / getchain

Method getchain

scapy/layers/tls/cert.py:1627–1655  ·  view source on GitHub ↗

Return a chain of certificate that points from a ROOT CA to a certificate.

(self, cert)

Source from the content-addressed store, hash-verified

1625 return tree
1626
1627 def getchain(self, cert):
1628 """
1629 Return a chain of certificate that points from a ROOT CA to a certificate.
1630 """
1631
1632 def _rec_getchain(chain, curtree):
1633 # See if an element of the current tree signs the cert, if so add it to
1634 # the chain, else recurse.
1635 for c, subtree in curtree:
1636 curchain = chain + [c]
1637 # If 'cert' is issued by c
1638 if cert.isIssuer(c):
1639 # Final node of the chain !
1640 # (add the final cert if not self signed)
1641 if c != cert:
1642 curchain += [cert]
1643 return curchain
1644 else:
1645 # Not the final node of the chain ! Recurse.
1646 curchain = _rec_getchain(curchain, subtree)
1647 if curchain:
1648 return curchain
1649 return None
1650
1651 chain = _rec_getchain([], self.tree)
1652 if chain is not None:
1653 return CertTree(chain)
1654 else:
1655 return None
1656
1657 def verify(self, cert):
1658 """

Callers 1

verifyMethod · 0.95

Calls 1

CertTreeClass · 0.85

Tested by

no test coverage detected