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

    ....

           }

  • 相关阅读:
    RedHat Openshift 搭建个人博客(wordpress)指南
    Sokcet方式请求HTTP/HTTPS的封装类HttpHelper
    不花钱的主机
    关于IE、火狐等浏览器兼容问题的总结
    ios平台调用WCF
    Windows Writer的服务提供器
    QQ开放平台 OAUTH2.0 QqConnetSDK 登录,运行原理,附源码。
    Learning Cocos2dx for XNA——深入剖析Hello World
    Albacore.NET下基于Rake(ruby make)的自动化构建工具
    排序算法
  • 原文地址:https://www.cnblogs.com/520cc/p/3092355.html
Copyright © 2011-2022 走看看