EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Export certificate from

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
Posted: 08/27/2014 11:05:26
by Rene Schoenfelder (Standard support level)
Joined: 08/27/2014
Posts: 3


I use an USB token for signatures: a TElWinCertStorage.

Now I would like export the certificate to a .cer file. How can I do that in C#?

(The method SaveToFile has no option .cer defined: https://www.eldos.com/documentation/sbb/documentation/ref_cl_certificate_mtd_savetofile.html)

Thank you,

Posted: 08/27/2014 11:07:59
by Eugene Mayevski (EldoS Corp.)

Find the certificate in TElWinCertStorage in some way (either by enumeration or by using Lookup object), then save the certificate (eg. "storage.get_Certiicates(1)") to .cer file using a call to TElX509Certificate.SaveToStream(InstanceOfFileStreamClass) method.

Sincerely yours
Eugene Mayevski
Posted: 08/27/2014 11:13:58
by Rene Schoenfelder (Standard support level)
Joined: 08/27/2014
Posts: 3

Thank you
Posted: 09/01/2014 15:26:30
by Rene Schoenfelder (Standard support level)
Joined: 08/27/2014
Posts: 3

The method SaveToStream returns an empty String:

TElX509Certificate Cert = getCertificate();
Cert.SaveToStream(new FileStream(path, FileMode.Create));

Also, it doesn't aks for my token password.
Posted: 09/01/2014 15:33:53
by Eugene Mayevski (EldoS Corp.)

First please inspect (with debugger) that Cert contains a certificate after a call to getCertificate(). "Contains" means an object with CertificateSize property greater than 0. This means that the certificate has been retrieved.

Now, in your code the stream is not closed. This means that the file will have zero length until the application exit (or for some other quite long time). Try to rewrite it to

Stream stream = new FileStream(path, FileMode.Create);

Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages



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