EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Sign XML and using TElXAdESSigner

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.
#11936
Posted: 12/14/2009 05:13:38
by Josep Saumell (Standard support level)
Joined: 04/11/2008
Posts: 15

Hi,
I'm sucessfully signing XML documents, but I would like to add XAdES options. I'm starting filling these properties before calling Sign method:

XAdESSigner := TElXAdESSigner.Create(nil);
Signer.XAdESProcessor := XAdESSigner;
XAdESSigner.XAdESVersion := XAdES_v1_3_2;

XAdESSigner.PolicyId.SigPolicyId.Description := '';
XAdESSigner.PolicyId.SigPolicyId.Identifier := '';
XAdESSigner.PolicyId.SigPolicyId.IdentifierQualifier := xqtNone;

XAdESSigner.SigningCertificates := TElMemoryCertStorage.Create(nil);
XAdESSigner.SigningTime := Now;

XAdESSigner.Generate;
XAdESSigner.QualifyingProperties.XAdESPrefix := 'xades';

Signer.UpdateReferencesDigest;
Signer.Sign;

I'm getting an "Access Violation" exception. Is there any property required in order to sign XML with XAdES information? Is there any problem with this code?

Thanks in advance.
Josep.
#11937
Posted: 12/14/2009 05:49:35
by Dmytro Bogatskyy (EldoS Corp.)

Quote
I'm getting an "Access Violation" exception. Is there any property required in order to sign XML with XAdES information? Is there any problem with this code?

Did you receive this exception on Sign or UpdateReferencesDigest method call?
This code is ok.
Does XMLBlackbox\Signer sample work as expected?
#11938
Posted: 12/14/2009 06:07:54
by Josep Saumell (Standard support level)
Joined: 04/11/2008
Posts: 15

The access violation is thrown in Save method (I'm writing below part of code I missed before)

Signer.Sign;
Signer.Signature.SignaturePrefix := 'ds';

AuxPointer := Pointer(TElXMLDOMNode(FXMLDocument).ChildNodes[0]);
SigNode := TElXMLDOMNode(AuxPointer);
Signer.Save(SigNode);

The sample works ok (Sorry, I'm a newbie in this kind of things...). I tried to fill same properties as in the sample, but I'm unable to get to work.
Thanks.
#11939
Posted: 12/14/2009 06:21:57
by Eugene Mayevski (EldoS Corp.)

Did you check that AuxPointer contains meaningful value? Most likely the problem is caused by that line, where AuxPointer is assigned.


Sincerely yours
Eugene Mayevski
#11940
Posted: 12/14/2009 06:24:56
by Dmytro Bogatskyy (EldoS Corp.)

Quote
AuxPointer := Pointer(TElXMLDOMNode(FXMLDocument).ChildNodes[0]);
SigNode := TElXMLDOMNode(AuxPointer);

Hmm, not sure what you will get here, I think it is better to write:
SigNode := FXMLDocument.DocumentElement;
#11941
Posted: 12/14/2009 06:41:45
by Josep Saumell (Standard support level)
Joined: 04/11/2008
Posts: 15

Hi Bogatskyy,
Your suggestion was ok, but same result: Access Violation when saving signature node.
I sent you here the whole units, may be it helps.
Any ideas? Remember, without XAdESSigner code part, it works.

Thanks a lot.


[ Download ]
#11943
Posted: 12/14/2009 07:03:36
by Dmytro Bogatskyy (EldoS Corp.)

Aha, you create a digital signature without any reference.
You should create a reference list:
Code
  Refs := TElXMLReferenceList.Create;
  Signer.References := Refs;


And add anything to sign. Without it a signature element doesn't make much sense.
To sign a document element add the following code:
Code
  Ref := TElXMLReference.Create;
  Ref.DigestMethod := xdmSHA1;
  Ref.URINode := FXMLDocument.DocumentElement;
  Ref.URI := '';
  Ref.TransformChain.Add(TElXMLEnvelopedSignatureTransform.Create);
  Refs.Add(Ref);
#11948
Posted: 12/14/2009 09:47:18
by Josep Saumell (Standard support level)
Joined: 04/11/2008
Posts: 15

Yes! Access violation solved.
I'll investigate my XAdES requirements in order to know which node I should sign.

You help me very much! Thanks again, Mr. Bogatskyy!
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.

Reply

Statistics

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