1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
- #pragma warning disable
- using System.Collections.Generic;
- using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
- using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
- using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
- using Best.HTTP.SecureProtocol.Org.BouncyCastle.X509;
- namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Cms
- {
- public class OriginatorInfoGenerator
- {
- private readonly List<Asn1Encodable> origCerts;
- private readonly List<Asn1Encodable> origCrls;
- public OriginatorInfoGenerator(X509Certificate origCert)
- {
- this.origCerts = new List<Asn1Encodable>{ origCert.CertificateStructure };
- this.origCrls = null;
- }
- public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs)
- : this(x509Certs, null, null, null)
- {
- }
- public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs, IStore<X509Crl> x509Crls)
- : this(x509Certs, x509Crls, null, null)
- {
- }
- public OriginatorInfoGenerator(IStore<X509Certificate> x509Certs, IStore<X509Crl> x509Crls,
- IStore<X509V2AttributeCertificate> x509AttrCerts, IStore<OtherRevocationInfoFormat> otherRevocationInfos)
- {
- List<Asn1Encodable> certificates = null;
- if (x509Certs != null || x509AttrCerts != null)
- {
- certificates = new List<Asn1Encodable>();
- if (x509Certs != null)
- {
- certificates.AddRange(CmsUtilities.GetCertificatesFromStore(x509Certs));
- }
- if (x509AttrCerts != null)
- {
- certificates.AddRange(CmsUtilities.GetAttributeCertificatesFromStore(x509AttrCerts));
- }
- }
- List<Asn1Encodable> revocations = null;
- if (x509Crls != null || otherRevocationInfos != null)
- {
- revocations = new List<Asn1Encodable>();
- if (x509Crls != null)
- {
- revocations.AddRange(CmsUtilities.GetCrlsFromStore(x509Crls));
- }
- if (otherRevocationInfos != null)
- {
- revocations.AddRange(CmsUtilities.GetOtherRevocationInfosFromStore(otherRevocationInfos));
- }
- }
- this.origCerts = certificates;
- this.origCrls = revocations;
- }
- public virtual OriginatorInfo Generate()
- {
- Asn1Set certSet = origCerts == null ? null : CmsUtilities.CreateDerSetFromList(origCerts);
- Asn1Set crlSet = origCrls == null ? null : CmsUtilities.CreateDerSetFromList(origCrls);
- return new OriginatorInfo(certSet, crlSet);
- }
- }
- }
- #pragma warning restore
- #endif
|