java - 导入 SSL 证书时出错 : Not an X. 509 证书

标签 java security ssl x509certificate

我正在尝试根据 this post 更新 SSL 证书 .

我是证书菜鸟,所以我关注 this guide .但是,当我输入

keytool -keystore mycacerts -storepass changeit -importcert -file "C:\Users\Noks\Desktop\cacerts.pem" -v

我得到错误:

keytool error: java.lang.Exception: Input not an X.509 certificate
java.lang.Exception: Input not an X.509 certificate
        at sun.security.tools.KeyTool.addTrustedCert(KeyTool.java:1913)
        at sun.security.tools.KeyTool.doCommands(KeyTool.java:818)
        at sun.security.tools.KeyTool.run(KeyTool.java:172)
        at sun.security.tools.KeyTool.main(KeyTool.java:166)

我该如何解决这个问题?

最佳答案

您的 cacerts.pem 文件是否包含一个证书?既然是 PEM,看一下(用文本编辑器),它应该以

开头

-----BEGIN CERTIFICATE-----

并以

结尾

-----END CERTIFICATE-----

最后,要检查它没有损坏,获取 openssl 并使用打印其详细信息

openssl x509 -in cacerts.pem -text

关于java - 导入 SSL 证书时出错 : Not an X. 509 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9889669/

相关文章:

Java (maven) 将 SSL 与 Shiro 结合使用 - Tomcat 7 的 https 端口插件无法正常工作

java - BigInteger 类中的无用变量,为什么?

javascript - 我可以发送没有表格的帖子吗?

security - HTTPS/SSL 在什么时候加密 POST 数据

ssl - Traefik 证书和路由功能

php - 我是否需要在 php header 中进行特殊设置才能生成 SSL 加密的 xml 输出?

java - Statement.executeQuery() 为 SELECT 语句返回什么

Java API 到 HBase 异常 :cannot get location

java - 在构造函数中使用派生类实例化基类引用

c - 使用哈希的 Shell 安全性