/// <summary> /// Decides if the given certificate pair should be selected. If /// <c>obj</c> is not a <code>X509CertificatePair</code>, this method /// returns <code>false</code>. /// </summary> /// <param name="obj">The <code>X509CertificatePair</code> to be tested.</param> /// <returns><code>true</code> if the object matches this selector.</returns> public bool Match( object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } X509CertificatePair pair = obj as X509CertificatePair; if (pair == null) { return(false); } if (certPair != null && !certPair.Equals(pair)) { return(false); } if (forwardSelector != null && !forwardSelector.Match(pair.Forward)) { return(false); } if (reverseSelector != null && !reverseSelector.Match(pair.Reverse)) { return(false); } return(true); }
public bool Match(object obj) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (obj == null) { throw new ArgumentNullException("obj"); } X509CertificatePair x509CertificatePair = obj as X509CertificatePair; if (x509CertificatePair == null) { return(false); } if (certPair != null && !certPair.Equals(x509CertificatePair)) { return(false); } if (forwardSelector != null && !forwardSelector.Match(x509CertificatePair.Forward)) { return(false); } if (reverseSelector != null && !reverseSelector.Match(x509CertificatePair.Reverse)) { return(false); } return(true); }
/// <summary> /// Search the given Set of TrustAnchor's for one that is the /// issuer of the given X509 certificate. /// </summary> /// <param name="cert">the X509 certificate</param> /// <param name="trustAnchors">a Set of TrustAnchor's</param> /// <returns>the <code>TrustAnchor</code> object if found or /// <code>null</code> if not. /// </returns> /// @exception internal static TrustAnchor FindTrustAnchor( X509Certificate cert, ISet trustAnchors) { IEnumerator iter = trustAnchors.GetEnumerator(); TrustAnchor trust = null; AsymmetricKeyParameter trustPublicKey = null; Exception invalidKeyEx = null; X509CertStoreSelector certSelectX509 = new X509CertStoreSelector(); try { certSelectX509.Subject = GetIssuerPrincipal(cert); } catch (IOException ex) { throw new Exception("Cannot set subject search criteria for trust anchor.", ex); } while (iter.MoveNext() && trust == null) { trust = (TrustAnchor) iter.Current; if (trust.TrustedCert != null) { if (certSelectX509.Match(trust.TrustedCert)) { trustPublicKey = trust.TrustedCert.GetPublicKey(); } else { trust = null; } } else if (trust.CAName != null && trust.CAPublicKey != null) { try { X509Name certIssuer = GetIssuerPrincipal(cert); X509Name caName = new X509Name(trust.CAName); if (certIssuer.Equivalent(caName, true)) { trustPublicKey = trust.CAPublicKey; } else { trust = null; } } catch (InvalidParameterException) { trust = null; } } else { trust = null; } if (trustPublicKey != null) { try { cert.Verify(trustPublicKey); } catch (Exception ex) { invalidKeyEx = ex; trust = null; } } } if (trust == null && invalidKeyEx != null) { throw new Exception("TrustAnchor found but certificate validation failed.", invalidKeyEx); } return trust; }