EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElCAdESSignatureProcessor.CreateBes exception...

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.
#21758
Posted: 09/29/2012 07:57:03
by igor andolski (Basic support level)
Joined: 09/29/2012
Posts: 10

Hi,

I have a problem with TElCAdESSignatureProcessor class.I'm trying to create a BES signature using the createBes method but I'm getting an exception: "Bad signature state".

here is the sample code:

Code
index=signer.AddSignature();
NewSignature = signer.get_Signatures(index);

cadesProcessor = new SBCAdES.TElCAdESSignatureProcessor(NewSignature);
cadesProcessor.CreateBES(Cert,ChainCert);


Thanks,
Igor
#21759
Posted: 09/29/2012 12:14:29
by Eugene Mayevski (EldoS Corp.)

What edition of SecureBlackbox are you doing this with?


Sincerely yours
Eugene Mayevski
#21760
Posted: 09/29/2012 12:17:01
by Eugene Mayevski (EldoS Corp.)

Also, from the code it is not clear where the signature comes from. It's very likely that it's really in the wrong state - CreateBES can work with signature object which has not been signed and you seem to be passing the actual signature to it.


Sincerely yours
Eugene Mayevski
#21767
Posted: 09/30/2012 14:31:36
by igor andolski (Basic support level)
Joined: 09/29/2012
Posts: 10

I use the latest edition of Secure BlackBox for .NET.

signer is a TElSignedCMSMessage object.
NewSignature is an empty signature linked to the signer object.
#21768
Posted: 09/30/2012 14:41:01
by Eugene Mayevski (EldoS Corp.)

Can you please show how the signer object is initialized? If it's initialized with some data, it would be nice if you could post the data as well.

There's no place in the code CreateBES to fail - it just checks the State property of the signature, so if your signature is in wrong state, this caused by some previous code which you have not provided.


Sincerely yours
Eugene Mayevski
#21769
Posted: 09/30/2012 15:55:38
by igor andolski (Basic support level)
Joined: 09/29/2012
Posts: 10

Here is the sample code:

Code

FileStream Input = new FileStream(InputFilePath, FileMode.Open, FileAccess.Read);

TElSignedCMSMessage signer = new TElSignedCMSMessage();

//PKCS#7 compatibility                                  
signer.ContentType = SBPKCS7.Unit.SB_OID_PKCS7_DATA;
signer.ContentVersion = 1;
signer.UseUndefSize = false;

signer.CreateNew(Input, 0, 0);

TElX509Certificate Cert = SystemStore.get_Certificates(index_sign);
TElMemoryCertStorage ChainCert = new TElMemoryCertStorage();
ChainCert.Add(Cert, false);
                                        
int index = signer.AddSignature();
signature = signer.get_Signatures(index);

cadesProcessor = new SBCAdES.TElCAdESSignatureProcessor(NewSignature);
cadesProcessor.CreateBES(Cert,ChainCert);//error!!!


Thanks.
#21771
Posted: 10/01/2012 04:33:22
by Ken Ivanov (EldoS Corp.)

Igor,

I suspect you've got some confusion with TElCMSSignature objects in your code (see lines 18 and 20):

int index = signer.AddSignature();
signature = signer.get_Signatures(index);

cadesProcessor = new SBCAdES.TElCAdESSignatureProcessor(NewSignature);
#21772
Posted: 10/01/2012 04:50:34
by igor andolski (Basic support level)
Joined: 09/29/2012
Posts: 10

hi Ivanov,

My mistake.In my program I use NewSignature everywere.It is not a confusion.

Code
FileStream Input = new FileStream(InputFilePath, FileMode.Open, FileAccess.Read);
TElSignedCMSMessage signer = new TElSignedCMSMessage();

//PKCS#7 compatibility                                  
signer.ContentType = SBPKCS7.Unit.SB_OID_PKCS7_DATA;
signer.ContentVersion = 1;
signer.UseUndefSize = false;

signer.CreateNew(Input, 0, 0);

TElX509Certificate Cert = SystemStore.get_Certificates(index_sign);
TElMemoryCertStorage ChainCert = new TElMemoryCertStorage();
ChainCert.Add(Cert, false);
                                        
int index = signer.AddSignature();
NewSignature = signer.get_Signatures(index); //

cadesProcessor = new SBCAdES.TElCAdESSignatureProcessor(NewSignature);
cadesProcessor.CreateBES(Cert,ChainCert);//error!!!

So not the confusion is the problem...Any ideas?

Thanks.
#21774
Posted: 10/01/2012 06:27:07
by Ken Ivanov (EldoS Corp.)

I've just rechecked your code with the latest assemblies and it worked flawlessly for me. Could you re-check that you are using the latest SecureBlackbox update (10.0.222) please?
#21777
Posted: 10/01/2012 09:32:36
by igor andolski (Basic support level)
Joined: 09/29/2012
Posts: 10

I updated the SecureBlackBox version from Version 9.1.217 to Version 10.0.222 but now I get some errors like :

1. 'SBUtils.Unit' does not contain a definition for 'StrToOID'
2. 'SBConstants.Unit' does not contain a definition for 'sbSSL3'
3. 'SBConstants.Unit' does not contain a definition for 'sbTLS1'
4. The type or namespace name 'TMessageDigest160' does not exist in the namespace 'SBUtils' (are you missing an assembly reference?)

It is a problem about compatibility I think.Any ideas?

Thanks,
Igor.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

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