Org.BouncyCastle.Pkix.PkixBuilderParameters.GetExcludedCerts C# (CSharp) Method

GetExcludedCerts() public method

Excluded certificates are not used for building a certification path.
public GetExcludedCerts ( ) : ISet
return ISet
		public virtual ISet GetExcludedCerts()
		{
			return new HashSet(excludedCerts);
		}

Usage Example

        private PkixCertPathBuilderResult Build(IX509AttributeCertificate attrCert, X509Certificate tbvCert, PkixBuilderParameters pkixParams, IList tbvPath)
        {
            if (tbvPath.Contains(tbvCert))
            {
                return(null);
            }
            if (pkixParams.GetExcludedCerts().Contains(tbvCert))
            {
                return(null);
            }
            if (pkixParams.MaxPathLength != -1 && tbvPath.Count - 1 > pkixParams.MaxPathLength)
            {
                return(null);
            }
            tbvPath.Add(tbvCert);
            PkixCertPathBuilderResult pkixCertPathBuilderResult = null;
            PkixAttrCertPathValidator pkixAttrCertPathValidator = new PkixAttrCertPathValidator();

            try
            {
                if (PkixCertPathValidatorUtilities.FindTrustAnchor(tbvCert, pkixParams.GetTrustAnchors()) != null)
                {
                    PkixCertPath certPath = new PkixCertPath(tbvPath);
                    PkixCertPathValidatorResult pkixCertPathValidatorResult;
                    try
                    {
                        pkixCertPathValidatorResult = pkixAttrCertPathValidator.Validate(certPath, pkixParams);
                    }
                    catch (Exception innerException)
                    {
                        throw new Exception("Certification path could not be validated.", innerException);
                    }
                    return(new PkixCertPathBuilderResult(certPath, pkixCertPathValidatorResult.TrustAnchor, pkixCertPathValidatorResult.PolicyTree, pkixCertPathValidatorResult.SubjectPublicKey));
                }
                try
                {
                    PkixCertPathValidatorUtilities.AddAdditionalStoresFromAltNames(tbvCert, pkixParams);
                }
                catch (CertificateParsingException innerException2)
                {
                    throw new Exception("No additional X.509 stores can be added from certificate locations.", innerException2);
                }
                ISet set = new HashSet();
                try
                {
                    set.AddAll(PkixCertPathValidatorUtilities.FindIssuerCerts(tbvCert, pkixParams));
                }
                catch (Exception innerException3)
                {
                    throw new Exception("Cannot find issuer certificate for certificate in certification path.", innerException3);
                }
                if (set.IsEmpty)
                {
                    throw new Exception("No issuer certificate for certificate in certification path found.");
                }
                foreach (X509Certificate x509Certificate in set)
                {
                    if (!PkixCertPathValidatorUtilities.IsSelfIssued(x509Certificate))
                    {
                        pkixCertPathBuilderResult = this.Build(attrCert, x509Certificate, pkixParams, tbvPath);
                        if (pkixCertPathBuilderResult != null)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception innerException4)
            {
                this.certPathException = new Exception("No valid certification path could be build.", innerException4);
            }
            if (pkixCertPathBuilderResult == null)
            {
                tbvPath.Remove(tbvCert);
            }
            return(pkixCertPathBuilderResult);
        }
All Usage Examples Of Org.BouncyCastle.Pkix.PkixBuilderParameters::GetExcludedCerts