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

    ....

           }

  • 相关阅读:
    并发基础(一) 线程介绍
    java基础(九) 可变参数列表介绍
    全球 43 亿 IPv4 地址已耗尽!IPv6,刻不容缓
    IPv6,无需操作就可升级?
    为什么 HTTPS 比 HTTP 安全
    从《国产凌凌漆》看到《头号玩家》,你就能全面了解5G
    再谈 APISIX 高性能实践
    API 网关的选型和持续集成
    尹吉峰:使用 OpenResty 搭建高性能 Web 应用
    鱼和熊掌可兼得?一文看懂又拍云 SCDN
  • 原文地址:https://www.cnblogs.com/520cc/p/3092355.html
Copyright © 2011-2022 走看看