探索充气城堡商店对象

Explore a bouncy castle store object

我的问题与Bouncy Castle i cannot get all certificate密切相关。

我使用的 BC 代码 https://www.bouncycastle.org/docs/pkixdocs1.4/org/bouncycastle/cms/CMSSignedData.html 略有不同。

  Store                   certStore = s.getCertificates();
  SignerInformationStore  signers = s.getSignerInfos();
  Collection              c = signers.getSigners();
  Iterator                it = c.iterator();

  while (it.hasNext())
  {
      SignerInformation   signer = (SignerInformation)it.next();
      Collection          certCollection = certStore.getMatches(signer.getSID());

      Iterator              certIt = certCollection.iterator();
      X509CertificateHolder cert = (X509CertificateHolder)certIt.next();

      if (signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert)))
      {
          verified++;
      }   
  }

我的目的是从 "certStore" 中提取所有证书(签名者 + 他们的颁发者),并根据特定的密钥库验证它们。

但是要从 certStore 中提取证书,只有 "certStore.getMatches"。

签名者显然只提取签名者并在"certStore.getMatches"中使用只提取签名者的证书(一个或多个)。

我必须控制每个证书,他的 CRL 他的日期,而不仅仅是签名者。

获取所有证书的第一步是使用空选择器

 ArrayList<X509CertificateHolder> listCertDatFirm = new ArrayList(store.getMatches(null));

那么你就有了一组证书;递归循环你可以重建正确的链。