EldoS | Feel safer!

Software components for data protection, secure storage and transfer

AS2 Help

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#27552
Posted: 12/03/2013 13:47:30
by John Wallwork (Basic support level)
Joined: 12/03/2013
Posts: 5

I'm brand new to Secure Blackbox and AS2 and was hoping for some help. I'm currently doing a quick and dirty proof of concept (POC) Web page that I hope to eventually use as a starting point for a full web app. When I load the Page for the first time, I get the following error:

Code
No certificates for signing specified (error code is 9991)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: SBASCommon.EElASSMIMESignatureError: No certificates for signing specified (error code is 9991)



However, if I refresh the browser the error goes away until the application pool is reset. I believe I am loading the the signing certificate correctly.
Code
SBCustomCertStorage.TElMemoryCertStorage storageSigning = new SBCustomCertStorage.TElMemoryCertStorage();

string fileName = "w:\\clients\\AS2Client\\Sample.cer";
string keyfileName = "w:\\clients\\AS2Client\\Sample.key";
FileStream stream = new FileStream(fileName, FileMode.Open);

try
{
TElX509Certificate cert = new TElX509Certificate();
string fileExt = Path.GetExtension(fileName);
cert.LoadFromStream(stream, 0);

FileStream key = new FileStream(keyfileName, FileMode.Open);
     try
       {
        cert.LoadKeyFromStream(key, 0);
       }
     catch { }
     finally
      {
       key.Close();
      }
storageSigning.Add(cert,true);
}
catch { }
finally
    {
    stream.Close();
    }
......
......
......
as2Message.Signature.CertStorage = storageSigning;
......
......
as2Message.Save(DataFile, "w:\\clients\\AS2Client\\AS2Test.as2m");


Is there some delay that occurs the first time the page is executed, that I need to account for while the certificate is loaded?

Thanks
John Wallwork
#27553
Posted: 12/03/2013 13:54:00
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

The delays of the web pages are a bit out of our area of expertise, however when the code is executed for the first time, .NET Framework loads and optionally JIT-compiles the assemblies "on the fly", when they are used. So the first access to certain assembly will cause certain delay.

But I don't think it's a delay that causes the problem (the delay seems to have no way to affect capability of the code to load the certificate from file).

Your code is correct yet you suppress all exceptions and don't check for error codes returned by LoadFromStream and LoadKeyFromStream methods. I think that maybe the file is not opened or read correctly when it's read for the first time. No idea, why, but you can add some logging and error checking to both method calls and catch statement. Then we'll be able to see what's going on there.


Sincerely yours
Eugene Mayevski

Reply

Statistics

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