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;
            }

  • 相关阅读:
    待重写
    待重写
    待重写
    ReflectionUtils使用
    kafka消费组、消费者
    待重写
    Map接口常用实现类学习
    利用httpClient发起https请求
    sql常用格式化函数及字符串函数
    method reference
  • 原文地址:https://www.cnblogs.com/hdl217/p/1846854.html
Copyright © 2011-2022 走看看