Пример #1
0
        private void DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection?extraStore)
        {
            CheckStateForDecryption();
            extraStore = extraStore ?? new X509Certificate2Collection();

            X509Certificate2Collection certs = new X509Certificate2Collection();

            PkcsPal.Instance.AddCertsFromStoreForDecryption(certs);
            certs.AddRange(extraStore);

            X509Certificate2Collection originatorCerts = Certificates;

            ContentInfo?newContentInfo = null;
            Exception?  exception      = PkcsPal.Instance.CreateRecipientsNotFoundException();

            foreach (RecipientInfo recipientInfo in recipientInfos)
            {
                X509Certificate2?cert = certs.TryFindMatchingCertificate(recipientInfo.RecipientIdentifier);
                if (cert == null)
                {
                    exception = PkcsPal.Instance.CreateRecipientsNotFoundException();
                    continue;
                }

                newContentInfo = _decryptorPal !.TryDecrypt(
                    recipientInfo,
                    cert,
                    null,
                    originatorCerts,
                    extraStore,
                    out exception);

                if (exception != null)
                {
                    continue;
                }

                break;
            }

            if (exception != null)
            {
                throw exception;
            }

            SetContentInfo(newContentInfo !);
        }
Пример #2
0
 internal RecipientInfoEnumerator(RecipientInfoCollection RecipientInfos)
 {
     _recipientInfos = RecipientInfos;
     _current        = -1;
 }