Reputation: 2463
I have created two different DSA keys using java keytool (defaults to 2048 and SHA256, so the 2nd one is explicitly created with length 1024):
keytool -genkey -keystore c:\test\dsa2048.p12 -storetype pkcs12 -storepass password -keypass password -alias dsa2048
keytool -genkey -keystore c:\test\dsa1024.p12 -storetype pkcs12 -storepass password -keypass password -alias dsa1024 -keysize 1024
I then imported these keys into the windows keystore.
When I read the windows keystore, Keystore.aliases() does not return these ids. It works fine when I use RSA as the keyalg, but DSA doesn't work. I am also able to load these ids if I create the keystore from the file system, but I need to load them from the windows cert store.
Is this expected or is there something else I need to do to see them? Is it possible that keytool is creating invalid ids? When I try to sign with these ids in Acrobat I'm getting an error there as well...
import java.io.FileInputStream;
import java.security.KeyStore;
import java.util.Enumeration;
public class WindowsKeyStoreTest
{
public static void main(String [] args) throws Exception
{
windowsKeystore();
}
public static void windowsKeystore() throws Exception
{
KeyStore keyStore = KeyStore.getInstance("Windows-MY");
keyStore.load(null, null);
Enumeration<String> aliases = keyStore.aliases();
while(aliases.hasMoreElements())
{
String alias = aliases.nextElement();
if(keyStore.isKeyEntry(alias))
{
System.out.println(alias);
}
}
}
}
Upvotes: 1
Views: 201