当我尝试使用 keytool
将证书导入 key 存储时,它显示:
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 证书添加到我的 key 存储中,没有任何问题。有人可以帮忙吗?有语法错误吗?我正在使用 Glassfish 3.1.2.2 和 java 7。
最佳答案
使用 -----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
关于java.io.IOException : Illegal footer when importing certificate using keytool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17543101/