Skip to content

java.lang.NoSuchMethodError: org.bouncycastle.asn1.x509.GeneralName.getDERObject()

I have done migrating project from itext2.1.7.jar to itext5.5.13.jar but While testing the pdf which are having signatures am getting the below error:

java.lang.NoSuchMethodError: org.bouncycastle.asn1.x509.GeneralName.getDERObject()

This is the method where I am getting error:

   public URI getCrlUri(X509Certificate certificate) {

              byte[] crlDistributionPointsValue = certificate.getExtensionValue(Extension.cRLDistributionPoints.getId());

              if (null == crlDistributionPointsValue) {

                     return null;


              CRLDistPoint distPoint=null;

              try {

                     distPoint = CRLDistPoint


              } catch (IOException e) {



              DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();

              for (DistributionPoint distributionPoint : distributionPoints) {

                     DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();

                     if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {



                     GeneralNames generalNames = (GeneralNames) distributionPointName.getName();

                     GeneralName[] names = generalNames.getNames();

                     for (GeneralName name : names) {

                           if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {




                            final DERIA5String derStr = DERIA5String.getInstance(name.getDERObject());



                           String str = derStr.getString();

                           URI uri = toURI(str);

                           return uri;



              return null;


In my class path I have placed: 1.bcprov-jdk15on-1.49.jar 2.bcpkix-jdk15on-1.49.jar 3.itextpdf-5.5.13.jar

BouncyCastle libs I have added according the pom.xml which I got while downloading itextpdf.

This project was built on following bouncy castle libs 1.bcmail-jdk16-143.jar 2.bcprov-jdk16-143.jar 3.bctsp-jdk16-1.44.jar

Can anyone please help to fix this issue.


When you update a dependency of your code (here: iText) and transitive dependencies along with it (here: BouncyCastle), and you use those transitive dependencies in your own code, too, then you must be prepared to also adapt your code to the changes in the transitive dependencies.

In this case you use GeneralName.getDERObject():

final DERIA5String derStr = DERIA5String.getInstance(name.getDERObject());

That method was present in earlier BouncyCastle versions, in particular the 1.30s. In the course of the 1.40s this method was replaced by getEncoded() or getEncoded("DER"). Thus, try something like:

final DERIA5String derStr = DERIA5String.getInstance(name.getEncoded("DER"));

Beware, though, in those days the BouncyCastle API was very volatile, you might have to adapt more of your code using BouncyCastle…

In a comment you mention

now I’m getting :java.lang.IllegalArgumentException: encoding error in getInstance: java.lang.ClassCastException: org.bouncycastle.asn1.DERTaggedObject cannot be cast to org.bouncycastle.asn1.DERIA5String

Please try

final DERIA5String derStr = DERIA5String.getInstance(name.getName());