EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Upgrade From XAdES-T to XAdES-A

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#35358
Posted: 01/04/2016 07:37:43
by Manuel Muñoz (Basic support level)
Joined: 12/09/2015
Posts: 2

Hi!

We have purchased HttpClient and XML packages from SecureBlackBox, and I'm trying to sign with XAdES-A level.

At the moment I could sign with XAdES-T level without any problem following "Implementing XAdES signing of data using SecureBlackbox" tutorial, but when I try to sign with the next level (XAdES-C), including the line: TSBXAdESValidity Validity = XAdESSigner.AddValidationDataRefs();

When this line is going to be executed, I receive this message: "QualifyingProperties object not found (or signature is not calculated)"

This is my code:

Dim Ref As New TElXMLReference
Ref.TransformChain.Add(New TElXMLEnvelopedSignatureTransform)
Ref.URI = ""
Ref.URINode = SigNode
Signer.References.Add(Ref)

' Setup Signer options.
' For example, using default ones: enveloped signature, RSA-SHA1 signature method and etc.

' Setup signer key data
Signer.KeyData = keyInfo


' calculate digest value for references
Signer.UpdateReferencesDigest()

' Filling XAdES info
' Setting XAdES version
XAdESSigner.XAdESVersion = SBXMLAdES.Unit.XAdES_v1_4_1

'XAdESSigner.AddCounterSignature(Signer)

XAdESSigner.PolicyId.SigPolicyHash.DigestMethod = SBXMLSec.Unit.DigestMethodToURI(SBXMLSec.Unit.xdmSHA1)
XAdESSigner.PolicyId.SigPolicyHash.DigestValue = SBXMLSec.Unit.CalculateDigest(crtIns.CertificateBinary, SBXMLSec.Unit.xdmSHA1)

' Place a code to setup Signed properties and Timestamp client
' [XAdES PLACE #1]
' setting up production place
XAdESSigner.Included = SBXMLAdESIntf.Unit.xipProductionPlace
XAdESSigner.ProductionPlace.City = "EL ESPINAR"
XAdESSigner.ProductionPlace.StateOrProvince = "SEGOVIA"
XAdESSigner.ProductionPlace.PostalCode = "40100"
XAdESSigner.ProductionPlace.CountryName = "SPAIN"

' adding claimed roles as text
XAdESSigner.Included = XAdESSigner.Included Or SBXMLAdESIntf.Unit.xipSignerRole
XAdESSigner.SignerRole.ClaimedRoles.AddText(XAdESSigner.XAdESVersion, doc, "Programmers")


'Set signing certificate
Dim signingCertList As New TElXMLCertIDList

signingCertList.AddCertificate(crtIns, SBXMLAdES.Unit.XAdES_C)

Dim signedSigProp As New TElXMLSignedSignatureProperties(SBXMLAdES.Unit.XAdES_C)

signedSigProp.SigningCertificate.Add(signingCertList.CertIDs(0))

Dim signedProp As New TElXMLSignedProperties(SBXMLAdES.Unit.XAdES_C)

signedProp.SignedSignatureProperties = signedSigProp

Dim qualProp As New TElXMLQualifyingProperties(SBXMLAdES.Unit.XAdES_C)

qualProp.SignedProperties = signedProp

XAdESSigner.QualifyingProperties = qualProp
' set signing time
XAdESSigner.SigningTime = DateTime.UtcNow


' Generating XAdES structure, specify desired XAdES form as parameter
XAdESSigner.Generate(SBXMLAdES.Unit.XAdES_C)

' Generating signature structure
Signer.GenerateSignature()
XAdESSigner.QualifyingProperties.SignedProperties.ID = "SignedPropertiesID"
' Creating timestamping components.

Try

tspClient.HTTPClient = httpClient
tspClient.URL = "http://tss.accv.es:8318/tsa"
httpClient.SocketTimeout = 20000 '20 seconds

' Adding signature time-stamp

k = XAdESSigner.AddSignatureTimestamp(tspClient)
If k <> 0 Then
Throw New Exception("Failed to time-stamp: " + k)
End If

Catch ex As Exception

End Try
' Signing and saving signature

' Place a code to extend XAdES form immediately after signing.
' Used, for example, if you want to specify own revocation info not auto collected one.
' [XAdES PLACE #2]

Dim attCertRefs As New TElXMLCompleteCertificateRefs(SBXMLAdES.Unit.XAdES_C)

XAdESSigner.QualifyingProperties.UnsignedProperties.UnsignedSignatureProperties.AttributeCertificateRefs = attCertRefs
XAdESSigner.AddValidationDataRefs()

Signer.Save(SigNode)

If I comment this new line and change XAdES-C to XAdES-T, the file is signed without errors.

So, where is my error? Should I set more properties before?

Regards!
#35359
Posted: 01/04/2016 07:40:38
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Technical Support is provided to customers with the linked Support Access Ticket. You will find your Support Access Ticket together with all the details about how to use it in the registration e-mail that we’ve sent to you upon the purchase. The procedure of linking the Support Access Ticket is described in the registration e-mail as well.

Reply

Statistics

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