Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.bouncycastle.asn1.x500.X500Name

    public X509Certificate createCertificate(X500Principal issuerDN, PrivateKey issuerKey, String name, Date notBefore, Date notAfter, PublicKey key) throws IllegalArgumentException {

try {

X500Name issuer = new X500Name(issuerDN.getName());

X500Name commonName = new X500Name(name);

BigInteger serial = BigInteger.valueOf(++m_serial);

SubjectPublicKeyInfo pubKeyInfo = convertToSubjectPublicKeyInfo(key);

X509v3CertificateBuilder builder = new X509v3CertificateBuilder(issuer, serial, notBefore, notAfter, commonName, pubKeyInfo);

X509CertificateHolder certHolder = JcaContentSignerBuilder(SIGNATURE_ALGORITHM).build(issuerKey));

return new JcaX509CertificateConverter().getCertificate(certHolder);


catch (IllegalArgumentException e) {

throw e;


catch (Exception e) {

throw new RuntimeException(e);



   Like      Feedback      org.bouncycastle.asn1.x500.X500Name

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner