EldoS | Feel safer!

Software components for data protection, secure storage and transfer

S/MIME sign with PKCS11

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
Posted: 08/07/2014 03:43:55
by Somer B. (Basic support level)
Joined: 08/07/2014
Posts: 7

I have modified MimeMaker_VS2010 sample project to use PKCS11 for S/MIME signing.
Modified part of menuItem_Assemble_Click is below.
When i debug application i see that correct certificate is added to SenderCertStorage (TElMemoryCertStorage), but i get "Sign message error code: 8194" at msg.AssembleMessage.
How can i solve this problem?

PKCS11CertStorage = new SBPKCS11CertStorage.TElPKCS11CertStorage();
PKCS11CertStorage.DLLName = @"C:\Windows\System32\eTPKCS11.dll";
Session = PKCS11CertStorage.OpenSession(0, true);
Session.Login((int)SBPKCS11Base.Unit.utUser, "****");
Cert = PKCS11CertStorage.get_Certificates(0);

SenderCertStorage.Add(Cert, true);
smime.EncoderSignCertStorage = SenderCertStorage;
Posted: 08/07/2014 03:58:03
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

This approach should work. Is it possible that you clean SenderCertStorage or close PKCS#11 session before AssembleMessage is called?
Posted: 08/07/2014 04:20:24
by Somer B. (Basic support level)
Joined: 08/07/2014
Posts: 7

Neither closed, nor cleaned.
At debug, i can see certificate at new "System.Collections.ArrayList.ArrayListDebugView(((SBCustomCertStorage.TElMemoryCertStorage)(((SBSMIMECore.TElMessagePartHandlerSMime)((msg.MainPart).MessagePartHandler)).EncoderSignCertStorage)).CertificateList)).Items[0]" while calling msg.AssembleMessage.
Rest of code is:
TAnsiStringStream sm = new TAnsiStringStream();
int res = msg.AssembleMessage(sm, "utf-8",  SBMIME.TElHeaderEncoding.heBase64, "base64", "base64", false);
Posted: 08/07/2014 04:26:40
by Vsevolod Ievgiienko (EldoS Corp.)

I've created a ticket for you where you can post the modified sample for investigation.

Also if you have a license, please assign the license ticket to your user account. The ticket itself and the procedure of it's use are specified in the registration e-mail that was sent to you upon license purchase.



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