hesaam jj

hesaam jj

  • NA
  • 1
  • 0

Convert to vb.net

Jan 4 2013 1:27 PM
  public class PermissiveCertificatePolicy
    {
        private PermissiveCertificatePolicy()
        {
        }
        private readonly string subjectName;
        private static PermissiveCertificatePolicy currentPolicy;
        PermissiveCertificatePolicy(string subjectName)
        {
            this.subjectName = subjectName;
            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertValidate);
        }

        public static void Enact(string subjectName)
        {
            currentPolicy = new PermissiveCertificatePolicy(subjectName);
        }

        bool RemoteCertValidate(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error)
        {
            if (subjectName == "*")
            {
                return true;
            }
            else if (cert.Subject == subjectName)
            {
                return true;
            }
            else return false;
        }
    }

Answers (2)