2 u010844588 u010844588 于 2015.06.20 14:05 提问

把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[] 数组,然后要把这个数组生成公钥并导入到证书中。
Csdn user default icon
上传中...
上传图片
插入图片