コード例 #1
0
ファイル: PDF4PLOT.cs プロジェクト: trigomargarida/DT4SM
        public override bool VerifyFile(string filePath, ref List <KeyValuePair <X509Certificate2, bool> > verifiedCMS)
        {
            PdfReader     Reader = new PdfReader(filePath);
            AcroFields    Fields = Reader.AcroFields;
            List <String> Names  = Fields.GetSignatureNames();
            List <KeyValuePair <X509Certificate2, bool> > UsedCertificates = new List <KeyValuePair <X509Certificate2, bool> >();
            bool Validation = false;

            foreach (String Signature in Names)
            {
                PdfPKCS7 CMS = Fields.VerifySignature(Signature);
                bool     currentValidation = CMS.Verify();
                UsedCertificates.Add(new KeyValuePair <X509Certificate2, bool>(new X509Certificate2(DotNetUtils.ToX509Certificate(CMS.SigningCertificate)), currentValidation));
                //If one signature fails, so does the global validation of the file
                if (!currentValidation)
                {
                    Validation = false;
                }
            }
            verifiedCMS = UsedCertificates;
            return(Validation);
        }