@@ -265,9 +265,13 @@ class XMLSigner(XMLSignatureProcessor):
265
265
listed under the `Algorithm Identifiers and Implementation Requirements
266
266
<http://www.w3.org/TR/xmldsig-core1/#sec-AlgID>`_ section of the XML Signature 1.1 standard are supported.
267
267
:type digest_algorithm: string
268
+ :param include_c14n_transform: If this parameter equal ``True`` c14n transformation will be included in ``Transform`` XML node.
269
+ This parameter is needed, because some software can uses hard restrictions on Transform XML node, that prohibit
270
+ include c14n transformation into Transform XML node.
271
+ :type include_c14n_transform: string
268
272
"""
269
273
def __init__ (self , method = methods .enveloped , signature_algorithm = "rsa-sha256" , digest_algorithm = "sha256" ,
270
- c14n_algorithm = XMLSignatureProcessor .default_c14n_algorithm ):
274
+ c14n_algorithm = XMLSignatureProcessor .default_c14n_algorithm , include_c14n_transform = True ):
271
275
if method not in methods :
272
276
raise InvalidInput ("Unknown signature method {}" .format (method ))
273
277
self .method = method
@@ -277,6 +281,7 @@ def __init__(self, method=methods.enveloped, signature_algorithm="rsa-sha256", d
277
281
self .digest_alg = digest_algorithm
278
282
assert c14n_algorithm in self .known_c14n_algorithms
279
283
self .c14n_alg = c14n_algorithm
284
+ self .include_c14n_transform = include_c14n_transform
280
285
self .namespaces = dict (ds = namespaces .ds )
281
286
self ._parser = None
282
287
@@ -481,7 +486,8 @@ def _build_sig(self, sig_root, reference_uris, c14n_inputs):
481
486
if self .method == methods .enveloped :
482
487
transforms = SubElement (reference , ds_tag ("Transforms" ))
483
488
SubElement (transforms , ds_tag ("Transform" ), Algorithm = namespaces .ds + "enveloped-signature" )
484
- SubElement (transforms , ds_tag ("Transform" ), Algorithm = self .c14n_alg )
489
+ if self .include_c14n_transform is True :
490
+ SubElement (transforms , ds_tag ("Transform" ), Algorithm = self .c14n_alg )
485
491
digest_method = SubElement (reference , ds_tag ("DigestMethod" ),
486
492
Algorithm = self .known_digest_tags [self .digest_alg ])
487
493
digest_value = SubElement (reference , ds_tag ("DigestValue" ))
0 commit comments