EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to get WindowsCertificates in C++ for PDF Signature

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#32489
Posted: 03/04/2015 09:55:13
by Burak Dağlı (Basic support level)
Joined: 03/03/2015
Posts: 8

Hi,

I had got WindowsCertificates in .NET application for PDF Signature as following
code:

TElWinCertStorage certStorage= new TElWinCertStorage();
TElX509Certificate Cert = certStorage.get_Certificates(i);
cmbCertificates.Items.Add(Issuer: " + Cert.IssuerName.CommonName);

But I can not get WindowsCertificates in C++ application for PDF Signature as following
code:

TElWinCertStorage *SystemStore = new TElWinCertStorage(NULL);
TElX509Certificate *Cert = SystemStore->get_Certificates(i);

Unfortunately Cert is null. How can I proceed?
#32493
Posted: 03/04/2015 11:16:03
by Dmytro Bogatskyy (EldoS Corp.)

Hello,

Quote

TElWinCertStorage *SystemStore = new TElWinCertStorage(NULL);
TElX509Certificate *Cert = SystemStore->get_Certificates(i);
Unfortunately Cert is null. How can I proceed?

Did you set SystemStores property? For example:
Code
SystemStore->get_SystemStores()->set_Text("MY");

Please try Samples\PKIBlackbox\WindowsStorage sample.
#32496
Posted: 03/04/2015 12:32:32
by Burak Dağlı (Basic support level)
Joined: 03/03/2015
Posts: 8

Thank you,
It works when I set text with "MY".

But I tried Samples\PKIBlackbox\WindowsStorage sample. Error is given at code block which:

std::vector<uint8_t> SerialNumber;
pCert->get_SerialNumber(SerialNumber);

Error Message: Vector iterator not dereferencable
#32497
Posted: 03/04/2015 13:12:29
by Dmytro Bogatskyy (EldoS Corp.)

Hello,
Quote
Error Message: Vector iterator not dereferencable

Are you compiling using Microsoft Visual C++?
Did you copy this code into your project or did you compile the sample?
Did you compile your project in debug or release mode?

Because, there are no binary compatibility guarantees for standard library classes across different library (^=compiler) versions or compiler options.
I.e. std::vector may have a different binary layout under /MT than under /MTd. Also different Optimization flag in program in debug mode (/Od) and static library (/Ox) could cause similar issue.
By default the static library is compiled in release mode, so if you are compiling your project in debug mode you will get this error message. To solve this issue please try to build a static library with a following command line:
Makefile.cmd vc x86 debug

Also, you may modify CPPFLAGS environment variable in WrapperSources\Makefile.vc to compile a static library with exactly your compiler options.
#32511
Posted: 03/05/2015 03:06:12
by Burak Dağlı (Basic support level)
Joined: 03/03/2015
Posts: 8

Hi,

I built a static library with "Makefile.cmd vc x86 debug". I had added "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC" to Environment Path. I copied this code into my QT project. I compile successful my QT project _MSVC2013_OpenGL_32bit Debug. But while it is running, error is occured which is Vector iterator not dereferencable.

If I comment out about serialnumber, error is not given and build successful and it works.

However, when the project is built release mode qt and static library is built for release mode, error is not given.
Error is given only at debug mode .

Also in documentation this page https://www.eldos.com/documentation/sbb/documentation/ref_cl_certificate_prp_serialnumber.html

void get_SerialNumber(std::string & OutResult) is a method and it takes string. But in sample it takes vector<uint8_t>.
#32512
Posted: 03/05/2015 03:41:05
by Dmytro Bogatskyy (EldoS Corp.)

Hi,
Quote
However, when the project is built release mode qt and static library is built for release mode, error is not given.
Error is given only at debug mode .

What is your debug settings? "Runtime library" and "Optimization" options?
"Makefile.cmd" for release configuration builds a static library using "/MD /Ox" options and for debug configuration builds using "/MDd /Od" options.
Quote

void get_SerialNumber(std::string & OutResult) is a method and it takes string. But in sample it takes vector<uint8_t>.

Thank you for pointing this out. We will fix this.
#32513
Posted: 03/05/2015 07:09:54
by Burak Dağlı (Basic support level)
Joined: 03/03/2015
Posts: 8

Hi,

In Qt Project there are two makefile. One is Makefile.debug , other is makefile.release. In makefile.release, there are lines as following :
CFLAGS = -nologo -Zm200 -Zc:wchar_t -FS -O2 -MD -Zc:strictStrings -W3 $(DEFINES)
CXXFLAGS = -nologo -Zm200 -Zc:wchar_t -FS -O2 -MD -Zc:strictStrings -GR -W3 -w34100 -w34189 -EHsc $(DEFINES)

In makefile.debug , there are lines as following:
CFLAGS = -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -W3 /Fddebug\WindowsStorage.pdb $(DEFINES)
CXXFLAGS = -nologo -Zm200 -Zc:wchar_t -FS -Zi -MDd -GR -W3 -w34100 -w34189 -EHsc /Fddebug\WindowsStorage.pdb $(DEFINES)
#32523
Posted: 03/05/2015 15:59:39
by Dmytro Bogatskyy (EldoS Corp.)

Hello,

Quote
In makefile.debug , there are lines as following:
...

Thank you for the detailed info.
We have reproduced this issue and working on fix now.
As a workaround, you can add "/D_ITERATOR_DEBUG_LEVEL=0" option in CPPFLAGS for debug configuration for the static library (in "WrapperSources\Makefile.vc") and for your project.
#32526
Posted: 03/06/2015 04:13:21
by Burak Dağlı (Basic support level)
Joined: 03/03/2015
Posts: 8

Hello,

Thank you very much. After I added this option, it works at QT debug mode.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

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