亦行天下 2015-06-20 06:05 采纳率: 12.5%
浏览 1982

把btyte数组生成公钥并导入到证书中,导入证书报错

byte[] key 是一个byte数组
InputStream in = new ByteArrayInputStream(key);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
Certificate certificate = certificateFactory.generateCertificate(in);
getTrustKeyStore().setCertificateEntry(alias, certificate);

然后在第四行就报错
java.security.cert.CertificateException: Unable to initialize, java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
at sun.security.x509.X509CertImpl.(X509CertImpl.java:182)
at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:90)
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:305)
at com.sc.SecretKeyImp.addCert(SecretKeyImp.java:313)
at com.sc.SecretKeyImp.writeKey2(SecretKeyImp.java:90)
at com.sc.SecretKeyImp.storeKey(SecretKeyImp.java:67)
at test.Demo.storeKey(Demo.java:91)
at test.Demo.main(Demo.java:70)
Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
at sun.security.util.DerInputStream.getLength(DerInputStream.java:544)
at sun.security.util.DerValue.(DerValue.java:235)
at sun.security.util.DerInputStream.getDerValue(DerInputStream.java:400)
at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1709)
at sun.security.x509.X509CertImpl.(X509CertImpl.java:179)
... 7 more

哪位大神指导怎么处理?求给指点!  就是去下载别人的RSA公钥,得到一个byte[] 数组,然后要把这个数组生成公钥并导入到证书中。
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog