EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Adding attribute to Signature element

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#29932
Posted: 06/25/2014 11:23:41
by Mauricio Ahumada (Basic support level)
Joined: 06/16/2014
Posts: 13

Hello, me again.
Im doing a XADES signature, using almost the same code as here https://www.eldos.com/security/articles/7895.php?page=1

It works, however I need to simply add a single attribute to the Signature node, for example, currently i have the following:

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>

But i need to write something like:

<ds:Signature ID="123456" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>

Optionally I would like to remote the xmlns:ds="..." attribute.

I could not find any method on the TElXMLSigner class.

Any help about this?
#29933
Posted: 06/25/2014 12:43:59
by Dmytro Bogatskyy (EldoS Corp.)

Hello,

Quote
But i need to write something like:

<ds:Signature ID="123456" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>

To add an Id to a Signature element you can use TElXMLSigner.Signature.ID property.
But, if you are including XAdES info, then the ID attribute will be generated automatically. And if you are modifying Signature.ID property, then you will need to change QualifyingProperties.Target property too. For example:
Code
XAdESSigner.Generate();
..
XAdESSigner.QualifyingProperties.Target = "#signature-1";
...
Signer.GenerateSignature();
...
Signer.Signature.ID = "signature-1";


Quote

Optionally I would like to remote the xmlns:ds="..." attribute.

Use a SignaturePrefix property, for example:
Code
Signer.GenerateSignature();
...
Signer.Signature.SignaturePrefix = "#default";
#29934
Posted: 06/25/2014 13:18:19
by Mauricio Ahumada (Basic support level)
Joined: 06/16/2014
Posts: 13

Thanks, the code you posted worked fine for including the ID attribute!

Code
XAdESSigner.Generate();
..
XAdESSigner.QualifyingProperties.Target = "#signature-1";
...
Signer.GenerateSignature();
...
Signer.Signature.ID = "signature-1";


An observation though... the ID was NOT generated automatically

Another thing, when using the line

Code
Signer.Signature.SignaturePrefix = "#default";


Only the prefix was gone, but i was looking for a way to remove the entire xmlns attribute. I know it is possible because when signing with the XMLSEC library, the Signature node does include the ds: prefix but not the xmlns namespace attribute declaration. Can that be done with secureBlackBox?
#29936
Posted: 06/25/2014 14:27:08
by Dmytro Bogatskyy (EldoS Corp.)

Quote
An observation though... the ID was NOT generated automatically

I wasn't able to reproduce this with XMLBlackbox\Signer and AdvancedSigner samples.
Could you please try your code on desktop (as I understand you are running on .Net CF).
Quote
Only the prefix was gone, but i was looking for a way to remove the entire xmlns attribute.

In this case set a SignaturePrefix property to the empty string. The prefix would be taken from a parent element that contains xmlns attribute with XML-DSig namespace URI.

Reply

Statistics

Topic viewed 904 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!