Android P(9.0) 证书加密算法变更

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jianjun2114/article/details/87912386

1.Android 9.0 起,不再支持BC提供者的加密算法

 

例如:

KeyPairGenerator.getInstance("RSA", "BC");

将抛出java.security.NoSuchAlgorithmException:The BC provider no longer provides an implementation for RSA.

 

修改方案: 使用默认RSA ,   KeyPairGenerator.getInstance("RSA");

 

2.生成证书申请的CSR

 

PKCS10CertificationRequest request = new PKCS10CertificationRequest(
      MD5WITHRSA,
      new X509Principal(DN), 
      publicKey, 
      null,
      privateKey);

抛出异常:java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for Signature.MD5withRSA.  Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.
bc提供者不在提供Signature.MD5withRSA的实现

修改方案:

PKCS10CertificationRequest request = new PKCS10CertificationRequest(
      MD5WITHRSA,
      new X509Principal(DN), 
      publicKey, 
      null,
      privateKey,
      null);
展开阅读全文

没有更多推荐了,返回首页