@@ -75,19 +75,25 @@ def payload_as_dict(self):
7575 )
7676
7777 @property
78- def raw_public_keys (self ) -> list [Any ]:
78+ def raw_public_keys (self ) -> list [Union [ bytes , dict ] ]:
7979 """
80- it returns the public key extract from x509 certificates
81- looking to both phdr and uhdr
80+ Extracts public keys from x509 certificates found in the MSO.
81+ This method searches for x509 certificates in both the protected header (phdr)
82+ and unprotected header (uhdr) of the COSE_Sign1 object. It handles certificate
83+ data in various formats, including:
84+ - `bytes`: Returns a list containing the raw bytes of the certificate.
85+ - `list`: Returns the list of certificates as-is.
86+ - `dict`: Wraps the dictionary in a list and returns it.
87+ If no valid x509 certificates are found, an `MsoX509ChainNotFound` exception
88+ is raised. Unexpected types are logged as warnings.
89+ :return: list[Any]: A list of certificates in their respective formats.
90+ :raises MsoX509ChainNotFound: If no x509 certificates are found.
8291 """
83- # _mixed_heads = self.object.phdr.items() | self.object.uhdr.items()
84-
8592 merged = self .object .phdr .copy ()
8693 merged .update (self .object .uhdr )
8794 _mixed_heads = merged .items ()
8895 for h , v in _mixed_heads :
8996 if h .identifier == 33 :
90- # return list(self.object.uhdr.values())
9197 if isinstance (v , bytes ):
9298 return [v ]
9399 elif isinstance (v , list ):
0 commit comments