EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Certificate selection wizard

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#30842
Posted: 10/01/2014 00:32:52
by Gregor  (Basic support level)
Joined: 10/01/2014
Posts: 6

I am struggling with certificate selection dialog. I would like to make a general applet which would run on all supported systems.
Till now I have achived to display certificates from the windows store with JNI support, but I don't know if it's possible to use JNI in applet and how to redistribute the dll with applet?

If I use the TElJavaCertStorage class, it doesn't list any cert (getCount() equals 0). I have found a thread on your forum and the code:


Code
1. import java.security.KeyStore;
2. import java.security.Provider;
3. import java.security.cert.X509Certificate;
4. import java.util.Enumeration;
5.
6. public class Main {
7. public static void main(String[] args) {
8. try {
9. Provider p = new sun.security.mscapi.SunMSCAPI();
10. KeyStore ks = KeyStore.getInstance("Windows-MY", p);
11. ks.load(null, null);
12.
13. Enumeration<String> e = ks.aliases();
14. while (e.hasMoreElements()) {
15. String alias = e.nextElement();
16.
17. X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
18. System.out.println(cert.getSubjectX500Principal().getName());
19. }
20. } catch (Exception ex) {
21. ex.printStackTrace();
22. }
23. }
24. }

The upper code lists certificates but as I said TelJavaCertStorage does not. The thread on the forum states »Moved the discussion to the Helpdesk. Lets continue there.« and I no solution there, do you know what the problem could be?

I have found another thread on your forum and there is also written »Answered in Helpdesk.«. What does this mean?

Thank you very much for all your help.
#30843
Posted: 10/01/2014 01:19:42
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

You should choose system stores to list by adding their names using TElJavaCertStorage.getSystemStores().add() method. The class supports "Windows-MY" and "Windows-ROOT" stores.
#30844
Posted: 10/01/2014 01:29:35
by Gregor  (Basic support level)
Joined: 10/01/2014
Posts: 6

Well, I did do that already, but although the getCount is 0.

What about JNI in applet?
#30845
Posted: 10/01/2014 01:41:45
by Vsevolod Ievgiienko (EldoS Corp.)

Could you post you code here - we'll check it.

Quote
What about JNI in applet?

You can use JNI module in applet. We have JNI modules for Windows/Linux/OSX. Note that applet should be signed to use JNI without problems.
#30847
Posted: 10/01/2014 03:28:42
by Gregor  (Basic support level)
Joined: 10/01/2014
Posts: 6

TElJavaCertStorage supports just Windows certificate store?
#30848
Posted: 10/01/2014 03:47:24
by Gregor  (Basic support level)
Joined: 10/01/2014
Posts: 6

And the code:

Code
   public static void main(String[] args) {
      try {
         SBUtils.setLicenseKey("key");
         JavaCertificateList();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   public static void JavaCertificateList()
   {
      TElJavaCertStorage CertStore = new TElJavaCertStorage();
      try
      {
         CertStore.getSystemStores().clear();
         CertStore.getSystemStores().beginUpdate();;
         CertStore.getSystemStores().add("Windows-MY");
         CertStore.getSystemStores().endUpdate();;
      }
      finally
      {
      }
      for (int i = 0; i < CertStore.getCount(); i++)
      {
         System.out.println (CertStore.getCertificate(i).getSubjectName().CommonName);
      }
   }
#30849
Posted: 10/01/2014 03:49:54
by Vsevolod Ievgiienko (EldoS Corp.)

It can be used with both Windows stores and AndroidKeyStore on Android. JNI based TElWinCertStorage can be used only on Windows.
#30850
Posted: 10/01/2014 04:59:59
by Vsevolod Ievgiienko (EldoS Corp.)

Please add SecureBlackbox.PKI.jar to dependencies of the project - this should help. We'll check why such dependency occurs.
#30851
Posted: 10/01/2014 05:12:01
by Gregor  (Basic support level)
Joined: 10/01/2014
Posts: 6

Yes, indeed this does help. Now it works. Thank you.

Do you have any examples how TElJavaCertStorage can be used on Android?

How about example of using JNI in applet?
#30852
Posted: 10/01/2014 05:16:37
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
Do you have any examples how TElJavaCertStorage can be used on Android?

We don't have examples but it is used the same way as on Windows. Just add 'AndroidKeyStore' to system stores list. Also it works only with Android API 18 and higher.

Quote
How about example of using JNI in applet?

You can use a sample from \secbboxjava\Samples\PKIBlackbox\JNI folder as a reference.
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

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