code: public static List<X509GeneralName> getX509GeneralNames(GeneralNames genNames)
      {
          if (genNames == null) {
              return null;
          }
  
          GeneralName[] names = genNames.getNames();
          List<X509GeneralName> x509names = new ArrayList<X509GeneralName>(names.length);
  
          for (GeneralName name : names) {
              switch (name.getTagNo()) {
                  case GeneralName.rfc822Name:
                      x509names.add(new X509Rfc822Name(name));
                      break;
                  case GeneralName.dNSName:
                      x509names.add(new X509DnsName(name));
                      break;
                  case GeneralName.directoryName:
                      x509names.add(new X509DirectoryName(name));
                      break;
                  case GeneralName.uniformResourceIdentifier:
                      x509names.add(new X509URI(name));
                      break;
                  case GeneralName.iPAddress:
                      x509names.add(new X509IpAddress(name));
                      break;
                  default:
                      x509names.add(new X509GenericName(name));
                      break;
              }
          }
  
          return x509names;
      }
docs: Convert general names from Bouncy Castle general names.
  
  @param genNames Bouncy castle general names.
  @return a list of X.509 general names.