2

我用来创建密钥库的源代码,

import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.cert.Certificate;

public class MainClass {

public static void main(String args[]) throws Exception {
String pass = "wshr.ut";
String alias = "mytest";
String name = "mykeystore";

FileInputStream in = new FileInputStream(name);
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(in, pass.toCharArray());

Certificate c = ks.getCertificate(alias);
in.close();
System.out.println(c);

}
}

运行时出错:

Exception in thread "main" java.io.EOFException
at java.io.DataInputStream.readInt(Unknown Source)
at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
at MainClass.main(MainClass.java:17)

你能给我任何想法或解决方案来解决这个问题吗?

4

0 回答 0