コード例 #1
0
ファイル: CAdESCRLSource.cs プロジェクト: 63l06ri5/CAdESLib
        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);
        }
コード例 #2
0
ファイル: CAdESSignature.cs プロジェクト: 63l06ri5/CAdESLib
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: CAdESSignature.cs プロジェクト: 63l06ri5/CAdESLib
 public CAdESSignature(CmsSignedData cms, SignerID id)
 {
     _cmsSignedData         = cms;
     this.signerInformation = BCStaticHelpers.GetSigner(cms, id);
 }