public override IList <X509Crl> GetCRLsFromSignature() { IList <X509Crl> list = new List <X509Crl>(); // Add certificates contained in SignedData foreach (X509Crl crl in cmsSignedData.GetCrls ("Collection").GetMatches(null)) { list.Add(crl); } // Add certificates in CAdES-XL certificate-values inside SignerInfo attribute if present SignerInformation si = BCStaticHelpers.GetSigner(cmsSignedData, signerId); if (si != null && si.UnsignedAttributes != null && si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsRevocationValues] != null) { RevocationValues revValues = RevocationValues.GetInstance(si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsRevocationValues].AttrValues[0]); foreach (CertificateList crlObj in revValues.GetCrlVals()) { X509Crl crl = new X509Crl(crlObj); list.Add(crl); } } return(list); }
public virtual bool CheckIntegrity(Document detachedDocument) { try { bool ret = false; SignerInformation si = null; if (detachedDocument != null) { // Recreate a SignerInformation with the content using a CMSSignedDataParser CmsSignedDataParser sp = new CmsSignedDataParser(new CmsTypedStream(detachedDocument.OpenStream()), _cmsSignedData.GetEncoded()); sp.GetSignedContent().Drain(); si = BCStaticHelpers.GetSigner(sp, signerInformation.SignerID); } else { si = signerInformation; } ret = si.Verify(SigningCertificate); return(ret); } catch (CertificateExpiredException) { return(false); } catch (CmsException) { return(false); } catch (IOException) { return(false); } }
public override IList <BasicOcspResp> GetOCSPResponsesFromSignature() { IList <BasicOcspResp> list = new List <BasicOcspResp>(); // Add certificates in CAdES-XL certificate-values inside SignerInfo attribute if present SignerInformation si = BCStaticHelpers.GetSigner(cmsSignedData, signerId); if (si != null && si.UnsignedAttributes != null && si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsRevocationValues] != null) { RevocationValues revValues = RevocationValues.GetInstance(si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsRevocationValues].AttrValues[0]); foreach (BasicOcspResponse ocspObj in revValues.GetOcspVals()) { BasicOcspResp bOcspObj = new BasicOcspResp(ocspObj); list.Add(bOcspObj); } } return(list); }
public override IList <X509Certificate> GetCertificates() { IList <X509Certificate> list = new List <X509Certificate>(); if (!onlyExtended) { logger.Info(cmsSignedData.GetCertificates("Collection").GetMatches(null).Count + " certificate in collection"); foreach (X509Certificate ch in cmsSignedData.GetCertificates("Collection").GetMatches(null)) { X509Certificate c = ch; logger.Info("Certificate for subject " + c.SubjectDN); if (!list.Contains(c)) { list.Add(c); } } } // Add certificates in CAdES-XL certificate-values inside SignerInfo attribute if present SignerInformation si = BCStaticHelpers.GetSigner(cmsSignedData, signerId); if (si != null && si.UnsignedAttributes != null && si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsCertValues] != null) { DerSequence seq = (DerSequence)si.UnsignedAttributes[PkcsObjectIdentifiers.IdAAEtsCertValues].AttrValues[0]; for (int i = 0; i < seq.Count; i++) { X509CertificateStructure cs = X509CertificateStructure.GetInstance(seq[i]); X509Certificate c = new X509Certificate(cs); if (!list.Contains(c)) { list.Add(c); } } } return(list); }
public CAdESSignature(CmsSignedData cms, SignerID id) { _cmsSignedData = cms; this.signerInformation = BCStaticHelpers.GetSigner(cms, id); }