@@ -75,19 +75,25 @@ def payload_as_dict(self):
75
75
)
76
76
77
77
@property
78
- def raw_public_keys (self ) -> list [Any ]:
78
+ def raw_public_keys (self ) -> list [Union [ bytes , dict ] ]:
79
79
"""
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.
82
91
"""
83
- # _mixed_heads = self.object.phdr.items() | self.object.uhdr.items()
84
-
85
92
merged = self .object .phdr .copy ()
86
93
merged .update (self .object .uhdr )
87
94
_mixed_heads = merged .items ()
88
95
for h , v in _mixed_heads :
89
96
if h .identifier == 33 :
90
- # return list(self.object.uhdr.values())
91
97
if isinstance (v , bytes ):
92
98
return [v ]
93
99
elif isinstance (v , list ):
0 commit comments