相关疑难解决方法(0)

SecurityException:未安装BC提供程序

编写代码以使用生成数字证书BouncyCastle.

这是导致问题的代码的基本部分.

public X509Certificate generateCertWithKeypair(KeyPair caPair)
            throws InvalidKeyException, SecurityException, SignatureException {
        X509V3CertificateGenerator v3CertGen = new X509V3CertificateGenerator();
        v3CertGen
                .setSerialNumber(BigInteger.valueOf(System.currentTimeMillis()));
        v3CertGen
                .setIssuerDN(new X509Principal("CN=cn, O=o, L=L, ST=il, C= c"));
        v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60
                * 60 * 24));
        v3CertGen.setNotAfter(new Date(System.currentTimeMillis()
                + (1000L * 60 * 60 * 24 * 365 * 10)));
        v3CertGen
                .setSubjectDN(new X509Principal("CN=cn, O=o, L=L, ST=il, C= c"));
        v3CertGen.setPublicKey(caPair.getPublic());
        v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
        X509Certificate generateX509Certificate = v3CertGen
                .generateX509Certificate(caPair.getPrivate());//**here**
        return generateX509Certificate;
    }
Run Code Online (Sandbox Code Playgroud)

面临例外

Exception in "main" java.lang.SecurityException: BC provider not installed!
    at …
Run Code Online (Sandbox Code Playgroud)

java security encryption cryptography bouncycastle

6
推荐指数
1
解决办法
4090
查看次数

安全"加密"提供程序在Android N中已弃用

用户在Android N中运行我的应用程序,他遇到了崩溃.我知道Google在Android N中弃用了Crypto提供程序,但是迁移旧加密数据的最佳方法是什么.

android

3
推荐指数
1
解决办法
5197
查看次数