CmsReader { public static CertStore createCertStore(Collection<X509Certificate> allCerts) { CollectionCertStoreParameters params = new CollectionCertStoreParameters(allCerts); try { return CertStore.getInstance("Collection", params, CryptInit.getProvider()); } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException e) { throw new RuntimeException(e.getMessage(), e); } } private  CmsReader(); static byte[] decryptAndVerify(
		byte[] encryptedData,
		List<X509Certificate> expectedSignatureCerts,
		X509Certificate recipientCertificate,
		PrivateKey recipientPrivateKey); static CertStore createCertStore(Collection<X509Certificate> allCerts);  }
@Test public void testCreateCertStore() throws Exception { X509Certificate c1 = (X509Certificate) X509CertBuilder.createTemporaryCert("cn1", "a1", "pass").getCertificate("a1"); X509Certificate c2 = (X509Certificate) X509CertBuilder.createTemporaryCert("cn2", "a2", "pass").getCertificate("a2"); CertStore certStore = CmsReader.createCertStore(Arrays.asList(c1, c2)); Collection<? extends Certificate> certs = certStore.getCertificates(new X509CertSelector() { @Override public boolean match(Certificate cert) { return true; } }); assertThat(certs, Matchers.containsInAnyOrder(c1, c2)); }