我使用android怎么样解析sm2证书呢?我之前使用Keystore.load(inputstream,pwd),但是每次到这一步就直接报错了,显示的错误是:java.io.IOException: exception decrypting data - java.lang.ClassCastException: 
com.android.org.bouncycastle.jcajce.provider.symmetric.util.BCPBEKey cannot be cast to org.bouncycastle.jce.provider.JCEPBEKey,真是郁闷,我这边使用的jar包涉及有:bcprov-jdk15-1.46还有topprovider,其他的没有了,请问有没有遇见过的?或者通过别的方式进行解析sm2证书的?

解决方案 »

  1.   

    下载了不少,基本上都是不支持pkcs12类型的sm2的解析的
      

  2.   

    我最近也在做android使用bouncycastle库也遇到这个问题。找到好几天。得出的结论:android不能使用bouncycastle库,目前还没找到解决方案。
    Bouncy Castle The Legion of the Bouncy Castle is a charity from Australia that has written Bouncy Castle, a widely used library that provides both a light-weight cryptography API and a Java Cryptography Extension (JCE) provider. The Android platform already ships with a cut-down and outdated version of Bouncy Castle (with small changes in order to make it work on Android). Consequently any attempt to build and use the latest full version of the library in your application, results in classloader conflicts.
      

  3.   

    DoubleCA的JCE可以解析SM2数字证书。DoubleCA的JCE实现了SM2算法的密钥协商,国密SM2、SM3、SM4算法全套都实现了,包括JAVA KeyStore,叫dcks,实现了SM2密钥对的存储,包括国密SSL,可以实现Tomcat的国密SSL功能。包括各种国密数字证书都可以免费制作。可在Android和各JAVA平台上使用。
      

  4.   

    DoubleCA greate!