5
當前我正在使用BouncyCastle庫來生成證書。事情是這樣的:如何在Java中生成多域(UCC)證書?
X509V3CertificateGenerator certGenerator = new X509V3CertificateGenerator();
certGenerator.setIssuerDN(rootCertificate.getSubjectX500Principal());
certGenerator.setSignatureAlgorithm("SHA1withRSA");
certGenerator.setSerialNumber(serial);
certGenerator.setNotBefore(notBefore);
certGenerator.setNotAfter(notAfter);
certGenerator.setPublicKey(rootCertificate.getPublicKey());
Hashtable<DERObjectIdentifier, String> attrs = new Hashtable<DERObjectIdentifier, String>();
Vector<DERObjectIdentifier> order = new Vector<DERObjectIdentifier>();
attrs.put(X509Principal.C, "RU");
// other attrs.put() calls here
order.addElement(X509Principal.C);
// other order.addElement() calls here
certGenerator.setSubjectDN(new X509Principal(order, attrs));
certGenerator.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(rootCertificate));
certGenerator.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(newKeyPair.getPublic()));
return certGenerator.generate(rootPrivateKey, "BC");
我可以在SubjectAltNames
字段添加到生成的證書?
回答你自己的問題很好,但你應該這樣做,作爲一個明確的答案(以便它更明顯,可以投票)。 –
@JoachimSauer:我試圖這樣做,但系統說我應該有rep> = 100或等待8個小時。所以我決定,這比沒有更好:) – vadipp
哦,是的,我明白了。有一些限制。我希望你不要介意,如果我把你的答案寫在下面(作爲社區維基,所以我不會得到任何代表)。 –