Discuss this help topic in SecureBlackbox Forum
XML: Reorder elements in KeyInfo element
To reorder elements of KeyInfo element of the signature you need to use TElXMLKeyInfo.Exchange() method of TElXMLKeyInfo object, which is generated in TElXMLSigner.GenerateSignature() and GenerateSignatureAsync() methods. This object is accessed via TElXMLSigner.Signature.KeyInfo property.
This code sample changes the order of X509Data and KeyValue elements:
C#:
TElXMLKeyInfoX509Data X509KeyData = new TElXMLKeyInfoX509Data(true);
X509KeyData.Certificate = Certificate;
X509KeyData.IncludeKeyValue = true;
Signer.KeyData = X509KeyData;
Signer.IncludeKey = true;
...
Signer.GenerateSignature();
...
Signer.Signature.KeyInfo.Exchange(0, 1); // where 0 and 1 is index of KeyInfo items
Delphi:
X509KeyData := TElXMLKeyInfoX509Data.Create(True);
X509KeyData.Certificate := Certificate;
X509KeyData.IncludeKeyValue := true;
Signer.KeyData := X509KeyData;
Signer.IncludeKey := true;
...
Signer.GenerateSignature();
...
Signer.Signature.KeyInfo.Exchange(0, 1); // where 0 and 1 is index of KeyInfo items