I am developing an NFe issuer and have an option in windows that allows you to select which certificate to use. I would like to know if anyone knows how to call this feature from windows using Java.
I am developing an NFe issuer and have an option in windows that allows you to select which certificate to use. I would like to know if anyone knows how to call this feature from windows using Java.
Try this way:
Imports
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.cert.CertificateException;
Function
KeyStore instance = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
instance.load(null, null);
Enumeration<String> dados = instance.aliases();
List<String> certificados = new ArrayList<String>();
while(dados.hasMoreElements())
{
certificados.add(dados.nextElement());
}
for (String cert : certificados)
{
System.out.println(cert);
}
Example: