code: public static GeneralNames getGeneralNames(X509GeneralName[] genNames)
      {
          GeneralName[] names = new GeneralName[genNames.length];
  
          int i = 0;
          for (X509GeneralName name : genNames) {
              if (name instanceof BcGeneralName) {
                  names[i++] = ((BcGeneralName) name).getGeneralName();
              } else {
                  throw new IllegalArgumentException("Unexpected general name: " + name.getClass().toString());
              }
          }
  
          return new GeneralNames(names);
      }
docs: Convert a collection of X.509 general names to Bouncy Castle general names.
  
  @param genNames a collection of X.509 general names.
  @return a bouncy castle general names.