Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide and use dialog boxes when using Microsoft Crypto API (Windows Certificate Store)

I want to leverage the Windows Certificate Store in my Java application. I am able to load a keystore from Windows-MY that has all the aliases/certs I need, but when loading it I am faced with a dialog box asking to "Please insert a smart card". If I click cancel on this a few times, they keystore still loads with the right content.

Is there a way to suppress this dialog box? Also is there a way to use the Windows certificate selection box from Java? The only answer I have seen on the net is this: https://social.msdn.microsoft.com/Forums/en-US/52dca221-1e05-44c1-8c45-9e0d4a807853/java-keystoreload-for-windowsmy-pops-up-insert-smart-card-window?forum=windowssecurity, but I don't want to have to remove anything because I don't expect the users to do that.

Here is how I am loading the keystore:

KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);
like image 271
Seephor Avatar asked Oct 27 '15 16:10

Seephor


1 Answers

I never tried to load the certificase through the keystore, but supplied them by means of System properties.

System.setProperty("javax.net.ssl.keyStoreType", "Windows-MY");
System.setProperty("javax.net.ssl.keyStore", "NONE");
System.setProperty("javax.net.ssl.trustStoreType", "Windows-ROOT");
System.setProperty("javax.net.ssl.trustStore", "NONE");

See also java SSL and cert keystore and How to use the Windows Keystore (MCS) with JDBC?

like image 154
hotzst Avatar answered Nov 03 '22 07:11

hotzst