创建密钥库时出错=> java.io.DataInputStream.readInt(未知来源)中线程“main”java.io.EOFException中的异常

时间:2013-06-20 14:34:17

标签: java security keystore jks

我创建密钥库时使用的源代码

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)

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

0 个答案:

没有答案