java.security.cert.CertificateParsingException:java.io.IOException:主题键,无法创建EC公钥

时间:2014-11-24 18:17:03

标签: java eclipse security file-io

嗨,我在执行程序时遇到此错误。我正在尝试从Keystrore读取证书,我收到以下错误:

java.security.cert.CertificateParsingException: java.io.IOException: subject key, Could not create EC public key
at sun.security.x509.X509CertInfo.<init>(X509CertInfo.java:171)
at sun.security.x509.X509CertImpl.parse(X509CertImpl.java:1781)
at sun.security.x509.X509CertImpl.<init>(X509CertImpl.java:196)
at sun.security.provider.X509Factory.engineGenerateCertificate(X509Factory.java:97)
at java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:747)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
......

这是我用来阅读证书的代码:

public static Certificate getCerticate(String KSpwd, String KSname, String alias) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException{

    //Before a keystore can be accessed, it must be loaded.
        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        // get user password and file input stream
        char[] password = KSpwd.toCharArray();
        java.io.FileInputStream fis = new java.io.FileInputStream(KSname);
        ks.load(fis, password);
        fis.close();


    //Get the certificate from the Key Store
        Certificate cert = ks.getCertificate(alias);

        return cert;
}

1 个答案:

答案 0 :(得分:0)

您必须在java.security文件中注释掉NSS提供程序,然后一切正常。