title: Create X509V3 Certificate with Customized Extension
body: <p>Is it possible to create a X509v3 certificate with customized extension so that in the certificate there will be some customized field and value, such as "Client's Attribute = User_A, iPhone, iOS 7"? </p>
  
  <p>I am currently using BouncyCastle but I am not sure how to add the extension that I want. I am still stuck at the first step to create certificatebuilder as follow:</p>
  
  <pre><code>KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
      keyGen.initialize(4096);
      KeyPair key = keyGen.generateKeyPair();
      PublicKey pub = key.getPublic();
      PrivateKey priv = key.getPrivate();
      X509v3CertificateBuilder v3Bldr = new JcaX509v3CertificateBuilder(issuerBuilder.build(), BigInteger.valueOf(3),
              new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30), new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)),
              subjectBuilder.build(), pub);
      ASN1ObjectIdentifier asn1iod =
              new ASN1ObjectIdentifier("1.2.3.4");     
      v3Bldr.addExtension(asn1iod,false,b);
  
      X509CertificateHolder certHldr = v3Bldr.build(new JcaContentSignerBuilder("SHA1WithRSA").setProvider("BC").build(priv));
  
      X509Certificate cert = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHldr);;
  </code></pre>
  
  <p>. What should I do next and how to add the customized extension?</p>
  
  <p>EDIT: I have tried to follow the example in <a href="https://stackoverflow.com/questions/16412315/creating-custom-x509-v3-extensions-in-java-with-bouncy-castle">here</a> but it gave me error Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/util/Encodable</p>