zoukankan      html  css  js  c++  java
  • 飞信发信息,解决证书问题


            private void button1_Click(object sender, EventArgs e)
            {
                ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
                ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); 
                string num = textBox1.Text;
                string contents = textBox2.Text;
                string url = "https://sms.api.bz/fetion.php?username=1511111111&password=11111111&sendto=" + num + "&message=" + contents;
                HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
                req.Method = "GET";
                using (WebResponse wr = req.GetResponse())
                {
                    MessageBox.Show("OK");
                }

            }
            internal class AcceptAllCertificatePolicy : ICertificatePolicy
            {
                public AcceptAllCertificatePolicy()
                {
                }

                public bool CheckValidationResult(ServicePoint sPoint,
                   X509Certificate cert, WebRequest wRequest, int certProb)
                {
                    // Always accept 
                    return true;
                }
            }
            private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return true;
            }

  • 相关阅读:
    浅谈T-SQL中的特殊联结
    浅谈T-SQL中的联接查询
    对AccessViolationException的一些总结
    浅谈JavaScript中的定时器
    浅谈跨域
    浅谈JavaScript中的Ajax
    浅谈JavaScript中的能力检测
    c# webConfig中的session超时详细设置
    c# session总结
    重启sql server服务两种方式
  • 原文地址:https://www.cnblogs.com/hdl217/p/1846854.html
Copyright © 2011-2022 走看看