MSCAPI certificate selection field in Java; SunMSCAPI?

I am experimenting with the relatively new security provider SunMSCAPI. I want to create a simple applet that causes the browser to pop up a certificate selection window. I will take it from there. I have googled it one way and down another. Any tips?

+3
source share
2 answers

I am working (struggling) on ​​something similar - albeit for a non-web application .. The only solution that has worked for me so far is to make JNI in C # (wrapped using MCPP).

+1
source

You can use the provider SunMSCAPIto create a local client key store. You can do this simply using this code:

KeyStore keyStore = KeyStore.getInstance("Windows-MY",new SunMSCAPI());
keyStore.load(null, null);

, , , getInstance():

SunMSCAPI providerMSCAPI = new SunMSCAPI();
Security.addProvider(providerMSCAPI);
KeyStore ks = KeyStore.getInstance("Windows-MY");
ks.load(null, null);

, , , java Windows.

, , , , :

package org.catcert.crypto.keyStoreImpl.windows;

import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;

import sun.security.mscapi.SunMSCAPI;

public class Example {

    public static void main(String args[]) throws Exception {
        KeyStore keyStore = KeyStore.getInstance("Windows-MY",new SunMSCAPI());
        keyStore.load(null, null);

        // copy to avoid concurrent problems with aliases...
        ArrayList<String> aliases = Collections.list(keyStore.aliases());
        for(String alias : aliases){
            System.out.println("keyEntry alias: " + alias);
            X509Certificate cert = (X509Certificate)keyStore.getCertificate(alias);
            System.out.println("Certificate subject: " +  cert.getSubjectDN());

        }
    }
}

, SunMSCAPI java 1.6, 64 ​​ java 1.7.

0

Source: https://habr.com/ru/post/1790343/


All Articles