EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Digital Signing on PDFs

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#31713
Posted: 12/19/2014 10:01:08
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

I am facing this problem again, I followed your article but I couldn't understand which part I missed in above code. Could you help me with this error "object reference not set to an instance of an object ". Which part I have missed in above code
#31714
Posted: 12/19/2014 10:10:57
by Eugene Mayevski (EldoS Corp.)

Please run the code in debugger and once the exception happens and debugger stops, capture the call stack and post it here.


Sincerely yours
Eugene Mayevski
#31716
Posted: 12/19/2014 23:54:37
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

at SBPKCS11Base.__Global.PKCS11CheckError(Int64 HLib, Int32 FunctionCode, UInt32 ResultCode)
at SBPKCS11Base.TElPKCS11SessionInfo.Login(Int32 UserType, String PIN)
at Sign_Pdf.Program.ReadCertificateData() in C:\DigitalSignature-USBToken\DigitalSignature\Sign_Pdf\Sign_Pdf\Program.cs:line 240

Hi, i am getting this msg at stack interface: line 240 is:
sessioninfo.Login(0, "12345678");

please refer sample above code
#31718
Posted: 12/20/2014 00:45:37
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

"pkcs11error ckR_session_read_only_ exists in c_login function"
I am getting this error in above stack interface
#31719
Posted: 12/20/2014 02:26:09
by Eugene Mayevski (EldoS Corp.)

Please use search sometimes.

The result code is returned by your device. It says "A read-only session already exists, and so the SO cannot be logged in". Most likely you are trying to login several times (probably from different threads).


Sincerely yours
Eugene Mayevski
#31720
Posted: 12/20/2014 02:56:18
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

I have searched this topic, but didn't found any result so i posted here.

I am trying to login only once, here is my code, i am getting same issue

pkcs11CertStorage.MonitorSlotEvents = true;
pkcs11CertStorage.DLLName = @"C:\Windows\System32\eps2003csp11.dll";
try
{
pkcs11CertStorage.Open();
TElPKCS11SlotInfo Slot = pkcs11CertStorage.Module.get_Slot(0);
// pkcs11CertStorage.Open();
try
{
sessioninfo = pkcs11CertStorage.OpenSession(0, true);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
sdata.StatusCode = -1;
sdata.Message = ex.Message;
return sdata;
}

sessioninfo.Login((0), "12345678");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
sdata.StatusCode = -1;
sdata.Message = ex.Message;
return sdata;
}


memoryCertStorage.Add(pkcs11CertStorage.get_Certificates(0), true);
sessioninfo.Close();

pkcs11CertStorage.Close();
#31721
Posted: 12/20/2014 04:05:58
by Eugene Mayevski (EldoS Corp.)

I meant searching Google for the PKCS#11 error code. The codes are standard, not ours.

I guess that maybe you are trying to pass the user PIN and not a security office PIN, while passing the user type as SecurityOffice (0 as the first parameter in Login method). Try passing 1 (regular user).


Sincerely yours
Eugene Mayevski
#31723
Posted: 12/20/2014 06:31:38
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

Thanks for your solution.
Sorry for bothering you again, In signing process i am getting an error that "Pkcs11 module not found"

sig.SigningTime = DateTime.UtcNow;
sig.Handler = publicKeyHandler;

// certStorage should contain at least one certificate with an associated private key.
publicKeyHandler.CertStorage = memoryCertStorage;
sig.WidgetProps.Locked = false;
sig.WidgetProps.AutoPos = false;
sig.WidgetProps.AutoSize = false;

sig.WidgetProps.Width = 40;
sig.WidgetProps.Height = 20;

sig.WidgetProps.AutoFontSize = false;
sig.WidgetProps.TitleFontSize = 5.0;
sig.WidgetProps.SectionTextFontSize = 3.0;
sig.WidgetProps.ShowTimestamp = false;
sig.WidgetProps.TimestampFontSize = 3;
sig.WidgetProps.SectionTitleFontSize = 5;
sig.WidgetProps.OffsetX = xpositionValue;
sig.WidgetProps.OffsetY = ypositionValue;
sig.WidgetProps.Print = true;
sig.WidgetProps.BackgroundStyle = TSBPDFWidgetBackgroundStyle.pbsDefault;
sig.WidgetProps.Background.Width = 20;
sig.WidgetProps.Background.Height = 20;
publicKeyHandler.CustomName = "Adobe.PPKMS";
//publicKeyHandler.SignatureType = TSBPDFPublicKeySignatureType.pstX509RSASHA1;
publicKeyHandler.SignatureType = TSBPDFPublicKeySignatureType.pstX509RSASHA1;
doc.Close(true);

Do i need to add module anywhere here??
#31724
Posted: 12/20/2014 07:41:13
by Dmytro Bogatskyy (EldoS Corp.)

Hello,

Quote
Sorry for bothering you again, In signing process i am getting an error that "Pkcs11 module not found"

You shouldn't close PKCS#11 session or dispose TElPKCS11CertStorage object while selected certificate is in use.
#31731
Posted: 12/21/2014 23:43:44
by sowjanya  (Standard support level)
Joined: 06/24/2014
Posts: 37

Thanks
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 2794 times

Number of guests: 3, 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!