sun.security.x509.X509CertImpl cannot be cast to iaik.x509.X509Certificate

1.3k views Asked by At

i extracted a certificate from a JKS keystore and attempted to cast it to iaik.x509.X509Certificate. it failed with sun.security.x509.X509CertImpl cannot be cast to iaik.x509.X509Certificate. is there a way to write it to iaik.x509.X509Certificate manually? code snippet -

        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        FileInputStream in = new FileInputStream(keystorePath);
        char[] keyPasswordChars = keyPassword == null ? new char[0] : keyPassword.toCharArray();
        try {
                trustStore.load(in, keyPasswordChars);
        } finally   {
                in.close();
        }
        Certificate cert = trustStore.getCertificate(alias);
        if (cert != null) {
            iaik.x509.X509Certificate  x509 = (iaik.x509.X509Certificate) cert;
            return x509;
        }

iaik.x509.X509Certificate is from Entrust - enttoolkit.jar

0

There are 0 answers