java.io.IOException:使用keytool导入证书时的页脚非法

时间:2013-07-09 08:06:29

标签: java glassfish ssl-certificate keytool

当我尝试使用keytool将证书导入密钥存储区时,它会显示:

keytool error: java.security.cert.CertificateException: java.io.IOException: Illegal footer: ----END CERTIFICATE-----
java.security.cert.CertificateException: java.io.IOException: Illegal footer: ----END CERTIFICATE-----
        at sun.security.provider.X509Factory.engineGenerateCertificates(X509Factory.java:337)
        at java.security.cert.CertificateFactory.generateCertificates(CertificateFactory.java:462)
        at sun.security.tools.KeyTool.installReply(KeyTool.java:2571)
        at sun.security.tools.KeyTool.doCommands(KeyTool.java:998)
        at sun.security.tools.KeyTool.run(KeyTool.java:340)
        at sun.security.tools.KeyTool.main(KeyTool.java:333)
Caused by: java.io.IOException: Illegal footer: ----END CERTIFICATE-----
        at sun.security.provider.X509Factory.checkHeaderFooter(X509Factory.java:590)
        at sun.security.provider.X509Factory.readOneBlock(X509Factory.java:575)
        at sun.security.provider.X509Factory.parseX509orPKCS7Cert(X509Factory.java:413)
        at sun.security.provider.X509Factory.engineGenerateCertificates(X509Factory.java:335)
        ... 5 more

我已成功将CA证书添加到我的密钥存储区,没有任何问题。有人可以帮忙吗?有语法错误吗?我正在使用Glassfish 3.1.2.2和java 7。

1 个答案:

答案 0 :(得分:2)

使用----- END CERTIFICATE -----而不是---- END CERTIFICATE -----

Java 7需要5个领先 - ,java 6可能没有。请参阅来源http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/sun/security/provider/X509Factory.java