code: public static CertStore fromSignedData(final CMSSignedData signedData) {
          CertificateFactory factory;
          try {
              factory = CertificateFactory.getInstance("X509");
          } catch (CertificateException e) {
              throw new RuntimeException(e);
          }
  
          Store certStore = signedData.getCertificates();
          Store crlStore = signedData.getCRLs();
  
          @SuppressWarnings("unchecked")
          Collection<X509CertificateHolder> certs = certStore.getMatches(null);
          @SuppressWarnings("unchecked")
          Collection<X509CRLHolder> crls = crlStore.getMatches(null);
  
          Collection<Object> certsAndCrls = new ArrayList<Object>();
  
          for (X509CertificateHolder cert : certs) {
              ByteArrayInputStream byteIn;
              try {
                  byteIn = new ByteArrayInputStream(cert.getEncoded());
              } catch (IOException e) {
                  LOGGER.error("Error encoding certificate", e);
  
                  continue;
              }
              try {
                  certsAndCrls.add(factory.generateCertificate(byteIn));
              } catch (CertificateException e) {
                  LOGGER.error("Error generating certificate", e);
              }
          }
  
          for (X509CRLHolder crl : crls) {
              ByteArrayInputStream byteIn;
              try {
                  byteIn = new ByteArrayInputStream(crl.getEncoded());
              } catch (IOException e) {
                  LOGGER.error("Error encoding crl", e);
  
                  continue;
              }
              try {
                  certsAndCrls.add(factory.generateCRL(byteIn));
              } catch (CRLException e) {
                  LOGGER.error("Error generating certificate", e);
              }
          }
  
          try {
              return CertStore.getInstance("Collection",
                      new CollectionCertStoreParameters(certsAndCrls));
          } catch (GeneralSecurityException e) {
              throw new RuntimeException(e);
          }
      }
docs: Converts a Bouncy Castle <tt>signedData</tt> object into a
  <tt>CertStore</tt>.
  <p>
  This method will extract all certificates and CRLs from the
  <tt>signedData</tt>. It makes <strong>no</strong> attempt to verify the
  integrity of the <tt>signedData</tt>.
  
  @param signedData
  the <tt>signedData</tt> to etract.
  @return the extracted certificates and CRLs.