zoukankan      html  css  js  c++  java
  • wcf 之旅ERROR安全模式Transport传输安全 (未能为 SSL/TLS 安全通道建立信任的解决办法)

     ----------------------源代码

    static void Main()
            {
                  // WARNING: This code is only needed for test certificates such as those created by makecert. It is
                // not recommended for production code.
                  PermissiveCertificatePolicy.Enact("CN = WIN-85QBE2LGCIQ");

                // Create a client with given client endpoint configuration
                CalculatorClient client = new CalculatorClient();

                // Call the Add service operation.
                double value1 = 100.00D;
                double value2 = 15.99D;
                double result = client.Add(value1, value2);        //执行到这里会报异常:未能为 SSL/TLS 安全通道建立信任
                Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

    -------------------------修改后代码

       private static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain,SslPolicyErrors sslPolicyErrors)
            {
                return true;
            }

      static void Main()
            {
                ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
                      // WARNING: This code is only needed for test certificates such as those created by makecert. It is
                // not recommended for production code.
                //  PermissiveCertificatePolicy.Enact("CN = WIN-85QBE2LGCIQ");

                // Create a client with given client endpoint configuration
                CalculatorClient client = new CalculatorClient();

                // Call the Add service operation.
                double value1 = 100.00D;
                double value2 = 15.99D;
                double result = client.Add(value1, value2);
                Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

    ....

           }

  • 相关阅读:
    golang常用
    防火墙企业案例2-部署企业及IDC机房上网网关
    PHP实现opentracing jaeger链路追踪
    在CentOS 8中,使用awk+sort+uniq进行Apache访问日志分析
    iptables企业案例
    iptables详解
    Docker的持久化存储和数据共享
    Linux网络tcp连接大量CLOSE_WAIT和TIME_WAIT状态的出现和解决方法
    mobile开发备忘
    jenkins 获取当前上传的分支的commit + url跳转
  • 原文地址:https://www.cnblogs.com/520cc/p/3092355.html
Copyright © 2011-2022 走看看