@@ -265,9 +265,13 @@ class XMLSigner(XMLSignatureProcessor):
265265 listed under the `Algorithm Identifiers and Implementation Requirements
266266 <http://www.w3.org/TR/xmldsig-core1/#sec-AlgID>`_ section of the XML Signature 1.1 standard are supported.
267267 :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
268272 """
269273 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 ):
271275 if method not in methods :
272276 raise InvalidInput ("Unknown signature method {}" .format (method ))
273277 self .method = method
@@ -277,6 +281,7 @@ def __init__(self, method=methods.enveloped, signature_algorithm="rsa-sha256", d
277281 self .digest_alg = digest_algorithm
278282 assert c14n_algorithm in self .known_c14n_algorithms
279283 self .c14n_alg = c14n_algorithm
284+ self .include_c14n_transform = include_c14n_transform
280285 self .namespaces = dict (ds = namespaces .ds )
281286 self ._parser = None
282287
@@ -481,7 +486,8 @@ def _build_sig(self, sig_root, reference_uris, c14n_inputs):
481486 if self .method == methods .enveloped :
482487 transforms = SubElement (reference , ds_tag ("Transforms" ))
483488 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 )
485491 digest_method = SubElement (reference , ds_tag ("DigestMethod" ),
486492 Algorithm = self .known_digest_tags [self .digest_alg ])
487493 digest_value = SubElement (reference , ds_tag ("DigestValue" ))
0 commit comments