有没有人遇到过这个问题?
我正在尝试使用 BouncyCastle 在 Android 中创建证书,但是一旦我添加了 BouncyCastle Provider Jar,我就会遇到 Java 堆空间问题,Eclipse 崩溃并出现 OutOfMemory 错误。
我所做的只是跟随,这类似于充气城堡中的示例代码,
public static X509Certificate createMasterCert(
PublicKey pubKey,
PrivateKey privKey)
throws Exception
{
//
// signers name
//
String issuer = "C=AU, O=The Legion of the Bouncy Castle, OU=Bouncy Primary Certificate";
//
// subjects name - the same as we are self signed.
//
String subject = "C=AU, O=The Legion of the Bouncy Castle, OU=Bouncy Primary Certificate";
//
// create the certificate - version 1
//
X509v1CertificateBuilder v1CertBuilder = new JcaX509v1CertificateBuilder(
new X500Name(issuer),
BigInteger.valueOf(1),
new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30),
new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)),
new X500Name(subject),
pubKey);
X509CertificateHolder cert = v1CertBuilder.build(new JcaContentSignerBuilder("SHA1withRSA").setProvider(BC).build(privKey));
return new JcaX509CertificateConverter().setProvider(BC).getCertificate(cert);
}