|
24 | 24 | ec="http://www.w3.org/2001/10/xml-exc-c14n#",
|
25 | 25 | dsig_more="http://www.w3.org/2001/04/xmldsig-more#",
|
26 | 26 | xenc="http://www.w3.org/2001/04/xmlenc#",
|
27 |
| - xenc11="http://www.w3.org/2009/xmlenc11#" |
| 27 | + xenc11="http://www.w3.org/2009/xmlenc11#", |
| 28 | + xades="http://uri.etsi.org/01903/v1.3.2#" |
28 | 29 | )
|
29 | 30 |
|
30 | 31 | def ds_tag(tag):
|
@@ -586,6 +587,13 @@ def _get_signature(self, root):
|
586 | 587 | else:
|
587 | 588 | return self._find(root, "Signature", anywhere=True)
|
588 | 589 |
|
| 590 | + def _get_certificates(self, signature, x509_data): |
| 591 | + certs = [cert.text for cert in self._findall(x509_data, "X509Certificate")] |
| 592 | + encapsulated_path = "ds:Object/xades:QualifyingProperties//xades:EncapsulatedX509Certificate" |
| 593 | + for encapsulated in signature.findall(encapsulated_path, namespaces=namespaces): |
| 594 | + certs.append(encapsulated.text) |
| 595 | + return certs |
| 596 | + |
589 | 597 | def _verify_signature_with_pubkey(self, signed_info_c14n, raw_signature, key_value, der_encoded_key_value,
|
590 | 598 | signature_alg):
|
591 | 599 | if der_encoded_key_value is not None:
|
@@ -823,7 +831,7 @@ def verify(self, data, require_x509=True, x509_cert=None, cert_subject_name=None
|
823 | 831 | if self.x509_cert is None:
|
824 | 832 | if x509_data is None:
|
825 | 833 | raise InvalidInput("Expected a X.509 certificate based signature")
|
826 |
| - certs = [cert.text for cert in self._findall(x509_data, "X509Certificate")] |
| 834 | + certs = self._get_certificates(signature, x509_data) |
827 | 835 | if len(certs) == 0:
|
828 | 836 | x509_iss = x509_data.find("ds:X509IssuerSerial/ds:X509IssuerName", namespaces=namespaces)
|
829 | 837 | x509_sn = x509_data.find("ds:X509IssuerSerial/ds:X509SerialNumber", namespaces=namespaces)
|
|
0 commit comments