EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Signing XML document at client side in browser

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#21197
Posted: 08/27/2012 06:13:14
by Dmytro Bogatskyy (EldoS Corp.)

Quote
Any ideas what I am doing wrong?

I can't say anything without seeing your code.
Anyway, please try to use a following code:
Code
  Verifier.Load(SignatureElement);
  if (XAdESVerifier.QualifyingProperties == null)
  {
    TElXMLDOMElement ObjElement = FXMLDocument.CreateElementNS(SBXMLDefs.Unit.xmlSignatureNamespace, "Object");
    Verifier.Signature.XMLElement.AppendChild(ObjElement);
    TElXMLDOMElement QPropElement = FXMLDocument.CreateElementNS(SBXMLDefs.Unit.xmlXAdESNamespace_v1_3_2, "QualifyingProperties");
    ObjElement.AppendChild(QPropElement);
    // set Target attribute
    if (!string.IsNullOrEmpty(Verifier.Signature.ID))
      QPropElement.SetAttribute("Target", "#" + Verifier.Signature.ID);
    else
    {
        string s = 'Signature-Id-' + SBUtils.Unit.IntToStr(SBUtils.Unit.SBRndGenerate(uint.MaxValue)));;
        Verifier.Signature.XMLElement.SetAttribute("Id", s);
        QPropElement.SetAttribute("Target", "#" + s);
    }

    // reload signature
    Verifier.Load(SignatureElement);
  }
#21200
Posted: 08/27/2012 08:23:51
by janjoris van der Lei (Priority Standard support level)
Joined: 08/16/2012
Posts: 14

Ok, this works. I can now add xades elements without any problem.

The only one I am still having a bit difficulties with is the timestamp.
I create a TSPClient with the following code:
Code
TElHTTPTSPClient TSPClient = new TElHTTPTSPClient();
                  
                    TSPClient.URL = "http://zeitstempel.dfn.de/";


I then do :
Code
xav.AddArchiveTimestamp(TSPClient);

but no timestamp is added to my document.
#21202
Posted: 08/27/2012 09:10:33
by Dmytro Bogatskyy (EldoS Corp.)

Quote

I then do :
Code
xav.AddArchiveTimestamp(TSPClient);

but no timestamp is added to my document.

What does AddArchiveTimestamp method returns?
TSP error code you can check here: http://www.eldos.com/documentation/sb...stamp.html

P.S. Did you set TSPClient.HTTPClient property with an instance of TElHTTPSClient?
#21212
Posted: 08/28/2012 01:30:15
by janjoris van der Lei (Priority Standard support level)
Joined: 08/16/2012
Posts: 14

Hmm, I added the HTTPClient but now I get this error. Did I do something wrong or is the HTTPClient in fact not included in our license?


#21213
Posted: 08/28/2012 01:39:55
by Vsevolod Ievgiienko (EldoS Corp.)

Hello.

Indeed its not included into your license. You can use evaluation key for testing purposes but you should buy HTTPBlackbox client for production.
#21218
Posted: 08/28/2012 08:33:14
by janjoris van der Lei (Priority Standard support level)
Joined: 08/16/2012
Posts: 14

Okay, Thank you.
I can now add all the unsignedproperties that I want. But how can I add signedproperties? I am still unable to add a signingtime etc.

I use an TElXMLSigner, and then do TElXMLSigner.CompleteAsyncSign.
After this I use the verifier to add the Xades tags, but I don't seem to find how to add the signedproperties.

Should I use a TElXAdESSigner for this? And if so, how should I do this with distributed cryptography?
#21223
Posted: 08/28/2012 11:18:20
by Dmytro Bogatskyy (EldoS Corp.)

Quote
But how can I add signedproperties? I am still unable to add a signingtime etc.

I use an TElXMLSigner, and then do TElXMLSigner.CompleteAsyncSign.
After this I use the verifier to add the Xades tags, but I don't seem to find how to add the signedproperties.

Should I use a TElXAdESSigner for this? And if so, how should I do this with distributed cryptography?

SignedProperties as stated from it name are signed, so they could be created and filled before the actual sign (for async sign: in the first step, before calling InitiateAsyncSign method). Yes, you should use TElXAdESSigner class in the same way as in normal signing.
#21234
Posted: 08/29/2012 07:38:37
by janjoris van der Lei (Priority Standard support level)
Joined: 08/16/2012
Posts: 14

This worked perfectly.
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 6686 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!